csvq
csvq copied to clipboard
missing support for comma as a decimal separator (SUM, AVG return NULL)
Hi. I'm sad to report the SUM function doesn't work as expected with floating point values.
Consider this example.csv
Col1;Col2;Col3 1;"Text1";1,01 2;"Text2";2,02 3;"Text3";3,03
When running
csvq -d ; "select min(Col3),max(Col3),sum(Col3) from example"
I get: +-----------+-----------+-----------+ | MIN(Col3) | MAX(Col3) | SUM(Col3) | +-----------+-----------+-----------+ | 1,01 | 3,03 | NULL | +-----------+-----------+-----------+`
Now consider example2.csv where I replaces commas for dots as floating point separator:
Col1;Col2;Col3 1;"Text1";1.01 2;"Text2";2.02 3;"Text3";3.03
When running
csvq -d ; "select min(Col3),max(Col3),sum(Col3) from example2"
now I get +-----------+-----------+---------------------+ | MIN(Col3) | MAX(Col3) | SUM(Col3) | +-----------+-----------+---------------------+ | 1.01 | 3.03 | 6.0600000000000005 | +-----------+-----------+---------------------+
Both examples give wrong results. What is happening?
Please advise.