Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add InputFormat and InputCulture attributes to have more fine grained control of Reading #40

Open
Tamayi opened this issue May 7, 2015 · 0 comments

Comments

@Tamayi
Copy link

Tamayi commented May 7, 2015

I am receiving some CSV files where I receive dates in the format yyyyMMddHHmmss and sometimes, yyyyMMdd. I would like to be able to desrialise these into proper DateTime objects.

06|T|1|NHRPL|57999|Minor Theatre|M|12000|T|20080414105034|20080414125034||AC||0|1|0|0|0|0|P||

The .NET framework allows parsing these values as:

string value = "20080414105034";
DateTime.Parse(value); 'FAILURE
DateTime.ParseExact(value, "yyyyMMddHHmmss", CultureInfo.InvariantCulture); 'SUCCESS

If we could optionally pass in those through settings, then it would really help to deal with these non-standard formats. Sometimes, the data does not follow standard formats for the FileCultureName property. This would then allow this sort of configuration:

[CsvColumn(FieldIndex = 9, InputFormat="yyyyMMddHHmmss", InputCulture="", OutputFormat="yyyyMMddHHmmss")]
public DateTime TransactionDate { get; set; }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant