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

前端 未结 6 1088
旧时难觅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:39

    """ When I open up the exported CSV in vim, all the text appears on one line, with ^M appearing between lines.

    From the docs, it seems that you can provide open with a row separator; however I am unsure what it should be in this case. """

    Read back a sentence ... ^M means keyboard Ctrl-M aka '\x0D' (M is the 13th letter of the ASCII alphabet; 0x0D == 13) aka ASCII CR (carriage return) aka '\r' ... IOW what Macs used to use as a line terminator before OS X.

提交回复
热议问题