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
csvq provides -d and -D for the delimiter separator. But very often, the delimiter is set to ; when the decimal point is , (and can't be used as field separator). So it is natural to provide a parameter for the decimal point separator. This will allow for example to use csv files exported from excel in many countries where the decimal point is , (the green ones on this map).
I concur. This would be great, but I suspect you can't simply make csvq take in floating point values with commas, because just like in regular SQL, comma is used to separate command/operator parameters, so 3,14 would be parsed as 3 and 14 thus we have to use 3.14.
However, if it was possible to make it so with changing the floating point from . to , and separator from , to ; this also meant ; was used instead of , by command parser, then that would be optimal.
At the very least, though, IMO, csvq should allow to format output to use comma as floating point by default
Cheers.
Certainly this feature would be better supported, but for the reasons mentioned by @githubuser181226 , I cannot immediately determine if it can be implemented.
For output, the function NUMBER_FORMAT can be used to convert floating point values into strings that uses the character specified as the decimal point.
and to set the missing separators accordingly to the present ones, as follows:
',' is the same as ',.' (when missing thousands separator is set to empty string)
';' is the same as ';,'
';·' is the same as ';·,' (for Malaysia, Singapore according to Wikipedia)
...
The three separators should be different.
It will be nice if -d and -D could accept also a country, like 'fr'. For this (at least for -D) the library golang.org/x/text/message can be used to produce the result.
And, I know I'm exaggerating, may be -d could accept auto to choose between , and ; (the two most common). github.com/csimplestring/go-csv can be used as starting point. I haven't checked if this library is correct or not, sorry. In python there is csv.Sniffer which can be used to guess the separators.
And if auto is done in a way to choose , if possible, it can be set as default (in place of ',').
Activity
githubuser181226 commentedon Nov 26, 2022
I concur. This would be great, but I suspect you can't simply make csvq take in floating point values with commas, because just like in regular SQL, comma is used to separate command/operator parameters, so
3,14would be parsed as3and14thus we have to use3.14.However, if it was possible to make it so with changing the floating point from . to , and separator from , to ; this also meant ; was used instead of , by command parser, then that would be optimal.
At the very least, though, IMO, csvq should allow to format output to use comma as floating point by default
Cheers.
mithrandie commentedon Nov 26, 2022
Certainly this feature would be better supported, but for the reasons mentioned by @githubuser181226 , I cannot immediately determine if it can be implemented.
For output, the function NUMBER_FORMAT can be used to convert floating point values into strings that uses the character specified as the decimal point.
kpym commentedon Nov 27, 2022
I have changed my mind, we don't need new parameter. The solution could be simply to let
-dand-Daccept strings in the following formatand to set the missing separators accordingly to the present ones, as follows:
','is the same as',.'(when missing thousands separator is set to empty string)';'is the same as';,'';·'is the same as';·,'(for Malaysia, Singapore according to Wikipedia)The three separators should be different.
It will be nice if
-dand-Dcould accept also a country, like'fr'. For this (at least for-D) the library golang.org/x/text/message can be used to produce the result.And, I know I'm exaggerating, may be
-dcould acceptautoto choose between,and;(the two most common).githubproxy.fjygbaifeng.eu.org/csimplestring/go-csv can be used as starting point. I haven't checked if this library is correct or not, sorry. In python there is csv.Sniffer which can be used to guess the separators.
And if
autois done in a way to choose,if possible, it can be set as default (in place of ',').kpym commentedon Nov 27, 2022
If
-d autois accepted, it can resolve #85 automatically.