Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

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