anki-dm
anki-dm copied to clipboard
Use "minimal" CSV quoting of data.csv
(Avoid quoting fields containing space, but not other special characters.)
Firstly, thank you for a really useful tool that makes collaborating on shared Anki decks far more convenient! (The structure anki-dm
uses is far easier to deal with than what CrowdAnki outputs directly.)
One slight issue is the quoting of fields in data.csv
. The vast majority of tools (spreadsheets, editors, programming language libraries) follow, by default, one of two conventions:
-
Quote (enclose in
"
) only fields that contain a comma, a quotation mark or a new line. ("minimal") -
Quote all fields. ("full")
Unfortunately, PHP is an exception, as its fputcsv
quotes fields that contain a comma, a quotation mark, a new line, a space or a tab. Also unfortunately, while the quoting character (usually "
) and the delimiting character (usually ,
) can be customised, quoting fields containing spaces apparently cannot be disabled. Hence, anki-dm
, which uses fputcsv
, generates CSVs where fields containing a space, but not any of the other "special" characters, are quoted.
This results in the issue that when somebody opens data.csv
in a spreadsheet and then saves it, many spurious "changes" are introduced, due to the differing quoting conventions (AFAICT while most tools can switch between 1. and 2. above (minimal and full quoting), or use different delimiters etc., none can be configured to follow PHP's convention). This can make reviewing changes more difficult and "pollute" git history.
Running composer index
does cause the spurious "changes" to disappear, but (based on the git history of Anki Ultimate Geography), which uses anki-dm
, people don't always run it for every commit. (Not to mention that fly-by contributors might not even install PHP, composer and anki-dm
.)
(The relevant issue at Anki Ultimate geography.).
In light of this, would it be possible for ank-dm
to switch to using "minimal" quoting? (Switching to "full" quoting would also be a step up from current behaviour, but I think that "minimal" quoting is preferable as it's the default for more tools.)
I have a slightly hacky patch for anki-dm
to use "minimal" quoting, for which I'll open a pull request.