csv module usage in w2k -> lineterminator in dialect?

Teuvo Eloranta teeloranTakeThisAway at sunpoint.net
Thu Feb 5 04:23:34 EST 2004


Hi,

I have a question regarding csv module usage in W2K
(ActivePython-2.3.2-232-win32-ix86)

http://www.python.org/doc/current/lib/csv-fmt-params.html says:
"lineterminator
     The string used to terminate lines in the CSV file. It defaults to
'\r\n'."

If I use:
lineterminator = '\n' in the dialect
the file ends get's generated in hex: 0D OA  (Carriadge return, new
line)

but if I use:
lineterminator = '\r\n' or the ready-made excel dialect, dialect='excel'

I get the file ends in hex: 0D 0D 0A
--> When Excel reads CSV file, every other line is empty.

Windows uses OD OA in the line end in text files, so shouldn't the
module produce it if set:
lineterminator = '\r\n', not lineterminator = '\n'?

thanks,

-Teuvo




More information about the Python-list mailing list