Fastercsv shows malformedCSVError, what am i doing wrong?

410 Views Asked by At

I am implementing in Ruby and i am running a project which reads a CSV file to add users.

but when i pick my file it just gives always the same error:

FasterCSV::MalformedCSVError in User importController#match

Illegal quoting on line 1.

my CSV file just exists of :

"RubenPersoon1","test","Bauwens","Ruben","[email protected]",0

anyone who knows what can be wrong?

1

There are 1 best solutions below

0
Simone Carletti On BEST ANSWER

Try to upgrade your FasterCSV gem version. With the latest version it works:

FasterCSV.parse_line '"RubenPersoon1","test","Bauwens","Ruben","[email protected]",0'
 => ["RubenPersoon1", "test", "Bauwens", "Ruben", "[email protected]", "0"] 
ruby-1.8.7-p352 :005 > FasterCSV.parse '"RubenPersoon1","test","Bauwens","Ruben","[email protected]",0'
 => [["RubenPersoon1", "test", "Bauwens", "Ruben", "[email protected]", "0"]]

Also, keep in mind that if you are on Ruby 1.9.2, FasterCSV is already included. Just require 'csv' and use the CSV class.