Ruby: cannot parse Excel file exported as CSV in OS X

前端 未结 6 1079
旧时难觅i
旧时难觅i 2021-02-03 10:52

I\'m using Ruby\'s CSV library to parse some CSV. I have a seemingly well-formed CSV file that I created by exporting an Excel file as CSV.

However CSV.open(filen

6条回答
  •  时光说笑
    2021-02-03 11:31

    Stripping \r characters seemed to work for me

    CSV.parse(File.read('filename').gsub(/\r/, ' ')) do |row|
      ...
    end
    

提交回复
热议问题