Skip to content

Comments

When (re-)generating the CSV file use minimal quoting#9

Open
aplaice wants to merge 1 commit intoOnkelTem:masterfrom
aplaice:minimal_csv_quoting
Open

When (re-)generating the CSV file use minimal quoting#9
aplaice wants to merge 1 commit intoOnkelTem:masterfrom
aplaice:minimal_csv_quoting

Conversation

@aplaice
Copy link

@aplaice aplaice commented Aug 22, 2019

(Quote only when the field contains , " or a new line, not when it contains a space, but not the other characters.)

This is a rather hack-ish solution. It's also the first PHP code that I've ever written (other than fiddling with mediawiki and wordpress templates several years ago), so it may well not be very pretty code. I haven't seen a noticeable slow-down when running composer index on the anki-ultimate-geography deck, though.

I decided to write with fputcsv to a temporary buffer and then patch this output, to avoid writing my own CSV parser and possibly introducing my own bugs.

(Quote only when the field contains `,` `"` or a new line, not when it
contains a space, but not the other characters.)

This is a rather hack-ish solution. It's also the first PHP code that
I've ever written (other than fiddling with mediawiki and wordpress
templates several years ago), so it may well not be very pretty
code. I haven't seen a noticeable slow-down when running `composer
index` on the anki-ultimate-geography deck, though.

I decided to write with fputcsv to a temporary buffer and then patch
this output, to avoid writing my own CSV parser and possibly introduce
my own bugs.
@aplaice
Copy link
Author

aplaice commented Aug 22, 2019

(This is obviously linked to #8.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant