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?
Note:
- This behavior can occur with Python 2 or 3.