The CSV import is tantalizing but fails to accommodate files in this common CSV format:
Day,Pageviews
" Friday, February 13, 2009","3,771"
" Saturday, February 14, 2009","2,856"
Importing results in this (quotes are converted into html entities, embedded commas erroneously break one field into multiple):
Day Pageviews
" Friday February 13 2009" "3 771"
" Saturday February 14 2009" "2 856"
PHP provides a function for parsing CSV data that might work better than the current method of reading the file with file() and then processing the array items with explode():
http://php.net/manual/en/function.fgetcsv.php
I realize there is no actual standard for CSV files, but OpenOffice really wants to surround fields with quotation marks.
Comments
Comment #1
kevin hankens commentedThis is nice. Here's a patch reading data using fgetcsv(). Please test it out and let me know if it does what you expect. I removed the check_plain() as well. I'm not 100% on that one, but I'm not sure we need it here.
Thanks for the tip!
Comment #2
yelvington commentedWorks great!
And I think you're right about removing check_plain() on data load ... seems that violates the Drupal "store raw / filter later" pattern.
Comment #3
kevin hankens commentedCommitted. I'm going to push a new release so that everyone gets to enjoy it :)
Thanks again for the help!