You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
The reason will be displayed to describe this comment to others. Learn more.
@jef-n are we sure that this works? I wrote a test case where it does not:
# use any locale with comma decimal separator
test_locale = 'it_IT.UTF-8'
orig_path = './test_data.shp'
# this file will have numbers with comma in the dbf
dest_path = './result.shp'
# end config
import sys, locale
from qgis.core import QgsVectorFileWriter, QgsVectorLayer, QgsApplication
# init QGIS
qgs = QgsApplication(sys.argv, False)
qgs.initQgis()
l = QgsVectorLayer(orig_path, 'test layer', 'ogr')
print 'feature Count %s' % l.featureCount()
old_locale = locale.getlocale(locale.LC_NUMERIC)
locale.setlocale(locale.LC_NUMERIC, test_locale)
QgsVectorFileWriter.writeAsVectorFormat(l, dest_path, 'UTF-8', l.crs(), 'ESRI Shapefile')
locale.setlocale(locale.LC_NUMERIC, old_locale)
msg = 'open %s with a text editor and you should find numbers separated by comma'
print msg % dest_path.replace('shp', 'dbf')
768f0e8
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That was supposed to avoid wrong decimal delimiters (ie. comma vs. points) - is that now handled elsewhere?
768f0e8
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Uhm... who works with strange locales anyway 😇
768f0e8
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jef-n are we sure that this works? I wrote a test case where it does not:
locale_bug.zip
do you want me to file a bug report?
768f0e8
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mbernasocchi I don't remember exactly, but I guess that's on me... Can you open a pull request with this (failing) unit test?