Fastercsv显示malformedCSVError,我做错了什么?

时间:2011-10-13 11:33:42

标签: ruby-on-rails ruby fastercsv

我在Ruby中实现,我正在运行一个项目,该项目读取CSV文件以添加用户。

但是当我选择我的文件时,它总是给出相同的错误:

FasterCSV::MalformedCSVError in User importController#match

Illegal quoting on line 1.

我的CSV文件存在:

“RubenPersoon1”, “测试”, “博旺”, “鲁”, “rub@gmail.com”,0

任何知道可能出错的人?

1 个答案:

答案 0 :(得分:0)

尝试升级您的FasterCSV gem版本。使用最新版本:

FasterCSV.parse_line '"RubenPersoon1","test","Bauwens","Ruben","rub@gmail.com",0'
 => ["RubenPersoon1", "test", "Bauwens", "Ruben", "rub@gmail.com", "0"] 
ruby-1.8.7-p352 :005 > FasterCSV.parse '"RubenPersoon1","test","Bauwens","Ruben","rub@gmail.com",0'
 => [["RubenPersoon1", "test", "Bauwens", "Ruben", "rub@gmail.com", "0"]]

另外,请记住,如果您使用的是Ruby 1.9.2,则已包含FasterCSV。只需require 'csv'并使用CSV类。