Forums | Admin

Discussion Forums: help

Start New Thread Start New Thread

 

By: James Gray
RE: Unquoted fields do not allow \r or \n [ reply ]  
2009-11-24 20:17
FasterCSV columns exactly as you described them:

#!/usr/bin/env ruby -wKU

require "rubygems"
require "faster_csv"

p FCSV.parse(DATA.read)

__END__
21,43,"Note:
blah this is a note",xyz,pdq

The third column was placed into one String, including the newline.

I did remove the spaces after your commas. I hope they aren't in the real data. If they are though, you could probably use :col_sep => ", " (note the space after the comma) instead.

Hope that helps.

By: Joe Cairns
RE: Unquoted fields do not allow \r or \n [ reply ]  
2009-11-24 20:01

Here is what's causing the issue
21, 43, "Note:
blah this is a note", xyz, pdq

The third data element comes from a form where the user typed in:

Note:
blah this is a note

Unfortunately, the software we're getting the csv from can't strip or escape the carriage return in the middle of the string.

I'm wondering if there's a way to tell FasterCSV to ignore the \r inside the double quoted string, or if there is any other way around this problem.

By: James Gray
RE: Unquoted fields do not allow \r or \n [ reply ]  
2009-11-24 19:38
FasterCSV tries to guess the line endings of your data. If it can't do that for whatever reason, you can specify what to use manually with code like :row_sep => "\r\n".

If that doesn't answer your question, please post some sample data so I can see the problem.

By: Joe Cairns
Unquoted fields do not allow \r or \n [ reply ]  
2009-11-24 16:14
Hi, I'm importing a csv generated by a third party system. The data is text data and does indeed include a carriage return, but the entire field is wrapped in double quotes.

Any ideas what's wrong?