CSV - Unquoted fields do not allow \r or \n (line 2)

后端 未结 8 1331
耶瑟儿~
耶瑟儿~ 2020-12-28 15:38

Trying to parse a CSV file, but still getting the error message Unquoted fields do not allow \\r or \\n (line 2)..

I found here at SO similar topic,

相关标签:
8条回答
  • 2020-12-28 16:35

    In my case I had to provide encoding, and a quote char that was guaranteed to not occur in data

    CSV.read("file.txt", 'rb:bom|UTF-16LE', {:row_sep => "\r\n", :col_sep => "\t", :quote_char => "\x00"})
    
    0 讨论(0)
  • 2020-12-28 16:36

    Another simple solution to fix the weird formatting caused by Excel is to copy and paste the data into Google spreadsheet and then download it as a CSV.

    0 讨论(0)
提交回复
热议问题