In Python 2.7 running on Windows XP pro:
import csv
outfile = file('test.csv', 'w')
writer = csv.writer(outfile, delimiter=',', quoting=csv.QUOTE_MINIMAL)
writer.writerow(['hi','dude'])
writer.writerow(['hi2','dude2'])
outfile.close()
It generates a file, test.csv, with an extra \r at each row, like so:
test.csv
hi,dude\r\r\nhi2,dude2\r\r\n
instead of the expected:
hi,dude\r\nhi2,dude2\r\n
Why is this happening, or is this actually the desired behavior?
In Python 3 (I haven't tried this in Python 2), you can also simply do
as per documentation.
More on this in the doc's footnote: