ledger csv output compatible with rfc 4180?

Skip to first unread message

Gina White

Nov 9, 2016, 7:54:30 PM11/9/16
to ledge...@googlegroups.com
Hi ledger folk,

I would like to import ledger data into my go program.  It looks like csv gets me pretty close, but I am running into a problem with how escaping is done.

The  go stdlib csv implementation is based on rfc 4180, which says that for double quotes to appear inside a field, they should be escaped with another double-quote i.e.

"field 1","this is ""another"" field"

but the csv that ledger is outputting escapes things like this:

"field 1","this is \"another\" field"

Is there a reasonable way to convince ledger to escape things according to rfc 4180?  Is there maybe another path besides csv I should be looking at?

- Gina

Gina White

Nov 9, 2016, 10:41:51 PM11/9/16
to ledge...@googlegroups.com
I found the code where fn_quoted lives and can imagine adding something called fn_quoted_rfc4180, based on that.  Does that seem like a good change?

- Gina

Donald Lam

Jan 15, 2023, 7:47:14 PM1/15/23
to Ledger
I have opened pull request 2168 to fix this. An earlier change wrote the new function "quoted_rfc4180", but that doesn't work for the simple but goofy reason that the Ledger expression parser considers that to be an amount (with quantity 4180 and commodity symbol "quoted_rfc").
Reply all
Reply to author
0 new messages