FasterCSV question

Given a pipe ‘|’ delimited file ala:
[email protected]:~$ cat pipedata
A|This is text|Is this supposed to error|
A|This is text|Is this supposed to error|
A|This is text|Is this supposed to error|
A|This is text|Is this supposed to “error”|
A|This is text|Is this supposed to “error”|
A|This is text|Is this supposed to “error”|
A|This is text|Is this supposed to “error”|
A|This is text|Is this supposed to “error”|
A|This is text|Is this supposed to “error”|
A|This is text|Is this supposed to “error”|
A|This is text|Is this supposed to “error”|
A|This is text|Is this supposed to “error”|

and scripting ala:

[email protected]:~$ cat pipedata.rb
require ‘rubygems’
require ‘faster_csv’

FasterCSV.foreach("/home/rthompso/pipedata", :col_sep => ‘|’) do |row|
# use row here…
next if row.empty?
puts row
end

Why are rows that contain quoted data deemed MalFormed?

On Nov 5, 2006, at 8:19 PM, Reid T. wrote:

A|This is text|Is this supposed to “error”|

This line is not a legal CSV format. To be correct it would need to be:

A|This is text|“Is this supposed to ““error”””|

Luckily, it’s a trivial format you shouldn’t need FasterCSV to
parse. You can break it down with:

fields = line.split("|")

Hope that helps.

James Edward G. II

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs