CSV Export invalid -- commas in numbers are not quoted
Version
1.12
What browsers are you seeing the problem on?
This problem isn't browser related
What happened?
When using the CSV export of a PNL statement (Reports -> Income Statement), I add multiple periods and run a report, and then click the CSV to download.
The generated CSV file exports with number formatting -- eg 10,234.23. When a comma appears, the value is not quoted, and so any program importing the file adds a new column, incorrectly.
What should have happened?
Either remove number formatting, or quote the numbers so that it does the right thing when exporting to CSV.
I would recommend doing both -- remove commas for thousand-place (US), and if a comma does appear in a value, quote the value.
The CSV should take the export setting for numbers from the current user (not ideal, I know); so, this should have a workaround by setting the user's number formatting to something that's compatible with the chosen field separator.
I got bit by this again... didn't see your note on the workaround.
There's a slightly different issue when using the CSV export on a GL report -- for those the export is useless, there are no newlines between rows so you just get all transactions output in one row!
Seems like we need a dedicated CSV formatter to properly handle the output?
There's a slightly different issue when using the CSV export on a GL report -- for those the export is useless, there are no newlines between rows so you just get all transactions output in one row!
Yep. You reported that earlier this year. A fix for it has been implemented by @nick-prater and was released in 1.12.9 (and all 1.13.x versions). You need to load a new "display_report.csv" template and the newline issue will be fixed.
Seems like we need a dedicated CSV formatter to properly handle the output?
We do: LedgerSMB::Template::Plugin::CSV.
Looking at the CSV formatter and the latest version of the template, quoting of any non-numeric values (that is values other than what matches "0-9.+-"), which should be quoting your numbers, since they contain "," characters. Which version of the template are you using? 1.1? 1.2?
We're using mostly just the stock LedgerSMB Docker container, so whatever version is in there?