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

Not work with new data format #1

Open
Radzhab opened this issue Jan 28, 2017 · 2 comments
Open

Not work with new data format #1

Radzhab opened this issue Jan 28, 2017 · 2 comments

Comments

@Radzhab
Copy link

Radzhab commented Jan 28, 2017

I download allcountries.txt. run code but its rise error
image

@FreeApophis
Copy link

The format hasn't changed and it works fine, as you see in the screenshot The Value is 42.64991 - which should be easily parsed by double.Parse ... but it doesn't: the Problem is probably your Russian setting.

Does Russian use "," to seperate the decimal?

Compile in a neutral culture or explicitly set the culture to a culture which uses a period for the decimal separator.

@RobThree
Copy link

RobThree commented Sep 7, 2018

Compile in a neutral culture

I'm not sure how one would do that?

or explicitly set the culture to a culture which uses a period for the decimal separator.

Indeed. You can do either:

this.Latitude = double.Parse(Fields[4], CultureInfo.InvariantCulture);
this.Longitude = double.Parse(Fields[5], CultureInfo.InvariantCulture);

Or, alternatively, use this as one of the first lines in your program:

Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;
Thread.CurrentThread.CurrentUICulture = CultureInfo.InvariantCulture;

Not that the latter changes the culture for the entire application, you might not want that.

Finally, you may want to take a look at NGeoNames (full disclosure: I'm the author) which handles all of the parsing for you.

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