Open wrinklenose opened 4 years ago
Using locale.atof seems to be system dependent.
On my ubuntu 20.04 this seems to work:
locale.setlocale(locale.LC_ALL, 'de_DE.UTF-8')
'de_DE.UTF-8'
locale.atof('1,200')
1.2
It doesn't work when running on an alpine image in docker though, see https://stackoverflow.com/questions/61761085/python-locale-not-working-on-alpine-linux
Is there maybe some other way to do this that is less system dependent?
Describe the bug Messytables should guess decimals correctly respecting the locale configuration. For example: In germany the
,
is used as decimal dot but a value1,200
is guessed as type "text".This issue was initially reported as ckan issue https://github.com/ckan/ckan/issues/5769 where I recognized it.
The type guessing seems to happen here: https://github.com/okfn/messytables/blob/51b736892a48e420ab313675f54901c77b446dec/messytables/types.py and seems to happen locale specific. (I think the magic happens in line 100:
value = locale.atof(value)
Unfortunately python seems to recognizes a dot as decimal point even if a german locale is set, which I could reproduce in my local environment: