Search code examples
ruby-on-railsrubycsvfastercsv

Error parsing CSV with FasterCSV gem (MalformedCSVError)


FasterCSV is raising MalformedCSVError (Illegal Quoting) in this line:

|0150|1161623|Medicamentos e genericos "EPP".|1423|PB|

This is the code:

FasterCSV.foreach(path_to_file, :col_sep => '|') do |row|
    ...
end

Any ideas? tks!!


Solution

  • There is also an option quote_char which defaults to ", try changing it to something, which you don't expect in your data. You might try nil but I have never tried that.

    FasterCSV.foreach(path_to_file, :col_sep => '|', :quote_char => "|") do |row|
      ...
    end