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.

CommentFileSizeAuthor
#1 tablefield.module.fgetcsv.patch2.77 KBkevin hankens

Comments

kevin hankens’s picture

Status: Active » Needs review
StatusFileSize
new2.77 KB

This 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!

yelvington’s picture

Works great!

And I think you're right about removing check_plain() on data load ... seems that violates the Drupal "store raw / filter later" pattern.

kevin hankens’s picture

Status: Needs review » Closed (fixed)

Committed. I'm going to push a new release so that everyone gets to enjoy it :)

Thanks again for the help!