James Gray
1/22/2009 12:34:00 AM
On Jan 21, 2009, at 3:50 PM, Alfredo Mesen wrote:
> Hello, I've been trying to monkey patch FCSV to allow escaped colsep
> characters within a field:
>
> FCSV.parse "here\\, it is, other fields" #need: [["here\\, it is",
> "other fields"]]
My advice is don't do this, unfortunately. :(
I've tried to add this feature to FasterCSV multiple times now. It's
very hard and I haven't been able to find a good way to do it for
general cases. I fully admit this is a failing of FasterCSV, it's
very dependent on the proper CSV format.
You probably have three reasonable choices:
* Feed FasterCSV a line at a time, rescue the MalformedCSVError, and
switch strategies on those lines
* Preprocess all lines to be sure they are valid CSV and then hand
them off
* Build your own parser
Sorry I wasn't more help.
James Edward Gray II