FasterCSV - 在不应该的情况下引发MalformedCSVError

时间:2009-09-01 20:38:39

标签: ruby parsing csv fastercsv

示例数据:

"iWine","Barcode","Location","Bin","Size","Valuation","Price","StoreName",\ "PurchaseDate","Note","Vintage","Wine","Locale","Country","Region","SubRegion",\ "Appellation","Producer","SortProducer","Type","Color","Category","Varietal",\ "MasterVarietal","Designation","Vineyard","WA","WS","IWC","BG","WE","JR",\ "RH","JG","GV","JK","LD","CW","CT","MY","BeginConsume","EndConsume"

"334142","15240542","Cellar","","750ml","","0","","","","2003",\
"Bodegas y Viñedos Alión Ribera del Duero","Spain, Castilla y León, Ribera del Duero","Spain",\
"Castilla y León","Unknown","Ribera del Duero","Bodegas y Viñedos Alión",\
"Alión, Bodegas y Viñedos","Red","Red","Dry","Tempranillo","Tempranillo","Unknown","Unknown",\
"","","","","","","","","","","","","91.3333333333333","","2011","2021"

FasterCSV坚持在解析此数据时引发MalformedCSVError,特别是在faster_csv.rb中第1616行引发​​

raise MalformedCSVError unless in_quotes

2 个答案:

答案 0 :(得分:0)

另外 - 你看过有关编码的相关帖子吗?

How do I import using FasterCSV a row with a name like "Ciarán"?

答案 1 :(得分:0)

我猜你遇到的问题是由非ascii字符引起的。

尝试用非重音替换它们,看看它是否有效。如果是,则必须在FasterCSV上使用:encoding选项来匹配文件的格式。