CSV.read第x行中的非法引用 [英] CSV.read Illegal quoting in line x
本文介绍了CSV.read第x行中的非法引用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我使用ruby CSV.read与大量数据。例如:
行53657中的非法引用
这将更容易忽略该行并跳过它,然后通过每个csv并修复格式化。
解决方案
我在一个类似 123,456的行中遇到了这个问题, c
问题是CSV解析器预期
解决方案使用除了之外的引号字符,不出现在我的资料中:
CSV.read(filename,:quote_char =>|)
/ p>
I am using ruby CSV.read with massive data. From time to time the library encounters poorly formatted lines, for instance:
"Illegal quoting in line 53657."
It would be easier to ignore the line and skip it, then to go through each csv and fix the formatting. How can I do this?
解决方案
I had this problem in a line like 123,456,a"b"c
The problem is the CSV parser is expecting "
, if they appear, to entirely surround the comma-delimited text.
Solution use a quote character besides "
that I was sure would not appear in my data:
CSV.read(filename, :quote_char => "|")
这篇关于CSV.read第x行中的非法引用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文