You could use :row_sep => :auto
:
:row_sep
The String appended to the end of each row. This can be set to the special:auto
setting, which requests that CSV automatically discover this from the data. Auto-discovery reads ahead in the data looking for the next"\r\n"
,"\n"
, or"\r"
sequence.
There are some caveats of course, see the manual linked to above for details.
You could also manually clean up the EOLs with a bit of gsub
ing before handing the data to CSV for parsing. I'd probably take this route and manually convert all \r\n
s and \r
s to single \n
s before attempting to parse the CSV. OTOH, this won't work that well if there is embedded binary data in your CSV where \r
s mean something. On the gripping hand, this is CSV we're dealing with so who knows what sort of crazy broken nonsense you'll end up dealing with.