Ruby unable to parse a CSV file: CSV::MalformedCSVError (Illegal quoting in line 1.)

后端 未结 9 2145
被撕碎了的回忆
被撕碎了的回忆 2021-02-03 22:17

Ubuntu 12.04 LTS

Ruby ruby 1.9.3dev (2011-09-23 revision 33323) [i686-linux]

Rails 3.2.9

Following is

9条回答
  •  再見小時候
    2021-02-03 23:05

    I just had an issue like this and discovered that CSV does not like spaces between the col-sep and the quote character. Once I removed those everything went fine. So I had:

    12,  "N",  12, "Pacific/Majuro"
    

    but once I gsubed out the spaces using

    .gsub(/,\s+\"/,',\"')
    

    resulting in

    12,"N",  12,"Pacific/Majuro"
    

    everything went fine.

提交回复
热议问题