Bug report #20053
decimal separator in csv files
|Affected QGIS version:||3.5(master)||Regression?:||No|
|Operating System:||Mac OSX 10.14.3||Easy fix?:||No|
|Pull Request or Patch supplied:||Yes||Resolution:||no timely feedback|
|Crashes QGIS or corrupts data:||No||Copied to github as #:||27875|
When opening cvs files with data that contains decimals separator with "." it change after opening in QGIS to "," the problem then is that when saving the csv file to GeoJson it will become a "string" instead of numbers. This habit has come with version 3, it does not do this in 2.18 (never had).
Fixes #20053 decimal separator in csv files
Actually it had nothing to do with CSV being the
source, but it was the json exporter passing
the values through all field formatters except for
This resulted in all fields using a 'Range' formatter
(which is the default for all numeric types) passing
through the formatter and being returned as strings
in the json. Worse, if the locale was not a "dot"
locale and decimal separator was on, the resulting
string could not be easily converted into its original
Now, instead of checking for the fallback formatter
only, there is a white list of formatters that
can be applied when we want a json.
This is a temporary solution because the "right" way
to do it would be either a flag in the formatter to
tell if it can be applied when converting to json
and/or other "data" formats (csv etc.) or a different
new method similar to representValue.
#5 Updated by Soren Lindqvist about 4 years ago
Alessandro Pasotti wrote:
Just to be sure: if you change your locale number formatting options to "English" or "C" in QGIS options general tab, does that fixes the problem (override current locale must be checked) ?
Yes, I did right now change the locale formatting options to "C", the import does not change the "." to "," and exporting to GeoJson is now correct. It seems like the locale settings override "." and also export it as such and turning it to a string instead of number.
Great if you have find the solutions.
#7 Updated by Alessandro Pasotti about 4 years ago
- Resolution set to fixed/implemented
Thanks for checking, actually I think that even with C locale the output was not entirely correct: you did not get the ',' decimal separator and you did not get the thousand group separator (like "'" in italian locale), but you still did get the numer as a string (surrounded by quotes).
#14 Updated by Alessandro Pasotti almost 4 years ago
- Status changed from Open to Feedback
Can you please provide some more detail and a step-by-step procedure and sample data to reproduce?
The original issue has been identified and fixed and it is protected by a test which is not failing, hence it highly likely that you have found a completely new issue.