I’ve got a CVS export from Excel that the csv module is barfing on, and
I’m wondering if there’s something I should be doing differently.
In particular, the CSV looks something like this:
row 1, field 1, field 2\r\n
row 2, “some\n
text”, field 2\r\n
CSV module (of mine) just does not expect the space just after field
delimiter(,) and before quote marker(").
0% ruby -rcsv -e ‘CSV::Reader.parse(%Q(“a”,“b”)) { |row| p row }’
[“a”, “b”]
0% ruby -rcsv -e ‘CSV::Reader.parse(%Q(“a”, “b”)) { |row| p row }’
/usr/local/lib/ruby/1.9/csv.rb:557:in get_row': CSV::IllegalFormatError (CSV::IllegalFormatError) from /usr/local/lib/ruby/1.9/csv.rb:506:in each’
from /usr/local/lib/ruby/1.9/csv.rb:484:in `parse’
from -e:1
Does Excel generates such a line? Hmm. It must be supported then, even
though it could be a option. Do you expect ‘a, “b”’ is parsed as
‘a,“b”’, not an error, right? What do you think about ‘a,junk"b"’ and
‘a,\t\r\n"b"’?