CSV.read Illegal quoting in line x

后端 未结 5 924
深忆病人
深忆病人 2020-12-08 04:16

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.\"         


        
5条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-08 04:36

    The liberal_parsing option is available starting in Ruby 2.4 for cases like this. From the documentation:

    When set to a true value, CSV will attempt to parse input not conformant with RFC 4180, such as double quotes in unquoted fields.

    To enable it, pass it as an option to the CSV read/parse/new methods:

    CSV.read(filename, liberal_parsing: true)
    

提交回复
热议问题