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

Customizable CultureInfo #66

Open
pepr opened this issue Dec 18, 2018 · 3 comments
Open

Customizable CultureInfo #66

pepr opened this issue Dec 18, 2018 · 3 comments

Comments

@pepr
Copy link

pepr commented Dec 18, 2018

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.

@phatcher
Copy link
Owner

@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.

@fretje
Copy link
Contributor

fretje commented Feb 26, 2019

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");

@phatcher
Copy link
Owner

@fretje Looks like a documentation improvement then rather than a code change

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

3 participants