CsvReader
CsvReader copied to clipboard
Customizable CultureInfo
Hello phatcher,
Firstly thanks for the nice tool.
Now, I am using the CsvReader
for importing the data in the Czech environment, where CultureInfo
prescribes using comma as a decimal separator. On the other hand, for CSV files, it is often the case when the data is internacional and it uses dot as the decimal separator.
I am having issues with reading a file with Decimal
values with dot (described at
https://stackoverflow.com/questions/53830123/lumenworks-csvreader-how-to-read-decimal-using-invariant-culture).
Peeking in the source, I have found the code like
decimal IDataRecord.GetDecimal(int i)
{
ValidateDataReader(DataReaderValidations.IsInitialized | DataReaderValidations.IsNotClosed);
return decimal.Parse(this[i], CultureInfo.CurrentCulture);
}
Could the culture info be replaced by CultureInfo.InvariantCulture
, or better (say), could it be replaced by a property that could be changed at the instance level?
Thanks and wishing you nice Christmas time and Happy new year. P.
@pepr I'm open to a pull request with this in, I'll have a look but I'm not sure I can get to it myself.
I had the same problem. I solved this by setting the current culture before reading the file, like so:
CultureInfo.CurrentCulture = CultureInfo.CreateSpecificCulture("nl-BE");
@fretje Looks like a documentation improvement then rather than a code change