I’ve got a script that generates and emails a CSV file to a number of users who are on Windows. One of the columns has line breaks within it, and when I open the generated file I get square boxes before the line breaks. Here’s an example in code of what I’m trying to do:
CSV.open("/tmp/reports.csv", "w") do |csv|
csv << ["Date", "Description", "Comments", "Status"]
csv << ["Foo","Bar","This\r\n is \r\n where \r\n my \r\n linebreaks \r\n are,"Baz"]
end
I’ve tried any number of linebreak and encoding combinations I can think of, but no joy. I suspect it’s related to this issue, but the solution involves doing something after the import, which I’d rather not saddle my users with, especially as I’m not dealing with technical users here.
Any ideas?
Try gsubbing the \r out: