CodeNoob CodeNoob - 1 year ago 61
Python Question

Does Python csv writer always use DOS end-of-line characters?

I realize that the csv library in Python always generates DOS end-of-line characters. Even if I use the

mode, even if I use Linux.

import csv

f = open('output.txt', 'wb');
writer = csv.writer(f)

The above code always uses
as the end of line separator. How can I make it use use

Answer Source

You can give your writer instance a custom lineterminator argument in the constructor:

writer = csv.writer(f, lineterminator="\n")