RFC: suppress digit group separators in CSV output ?

20 views
Skip to first unread message

Simon Michael

unread,
Dec 5, 2021, 5:19:36 PM12/5/21
to hledger
https://github.com/simonmichael/hledger/pull/1771 proposes to not display thousands separators (more generally, "digit group separators") in numbers in CSV output. 

The rationale is that it's more often important for CSV output to be easily machine-readable (as when exporting data for charting), than to be human-readable (as when exporting data into a spreadsheet for making a pretty report).

Always suppressing digit group separators in CSV output is a simple non-confusing rule, but do you have any objection ? Do you think it should be optional, or made conditional on the --layout mode (see https://hledger.org/dev/hledger.html#commodity-layout) ?


Henning Thielemann

unread,
Dec 5, 2021, 5:25:19 PM12/5/21
to hledger
Digit group separators in CSV are a constant source of problems, because
they differ between languages. In English it is ",", in German it is ".".
If I import an English CSV in LibreOffice with German locales then
LibreOffice will recognize the comma as German fraction separator. (It
also means that fractions are problematic in CSV files.)

Simon Michael

unread,
Dec 5, 2021, 5:36:45 PM12/5/21
to hledger
I consider the identity of the digit group mark and decimal mark (ie, which character they are) to be a separate issue. That can be controlled (separately for each commodity, currently) by the -c/--commodity-style option, https://hledger.org/hledger.html#commodity-styles . This we can't hard-code, because of the different decimal marks used around the world.  



morgan.s...@gmail.com

unread,
Dec 5, 2021, 7:22:43 PM12/5/21
to hledger
Perhaps no surprise to anybody, but I am in favour of this change. As is I have to stick a bunch of --commodity-style="999999999.99 ABC" arguments whenever I'm generating csv to manually suppress the digit grouping separators.

As an aside, using a comma as a digit separator isn't even universal in English. I use a space, and I was taught this in school. It's also an ISO standard. I believe this is fairly common among English-speaking Canadians, due to the need to avoid confusion with the French convention also used in Canada.

Henning Thielemann

unread,
Dec 5, 2021, 7:25:16 PM12/5/21
to hledger

On Sun, 5 Dec 2021, morgan.s...@gmail.com wrote:

> As an aside, using a comma as a digit separator isn't even universal in
> English. I use a space, and I was taught this in school. It's also an
> ISO standard. I believe this is fairly common among English-speaking
> Canadians, due to the need to avoid confusion with the French convention
> also used in Canada.

Interesting. A space is also an accepted digit group separator in German.

the.so...@gmail.com

unread,
Dec 6, 2021, 5:54:38 AM12/6/21
to hledger
I'm agnostic to whether this is done for all CSV output, though I think it is a good idea.

But at the very least, --layout=bare (and the future --layout=tidy) should render *all* csv output amounts without digit group separators, since those two are clearly meant for machine-readability.



Reply all
Reply to author
Forward
0 new messages