csv module usage in w2k -> lineterminator in dialect?

T

Teuvo Eloranta

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
 
S

Skip Montanaro

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

Make sure you open the file with the 'b' flag.

Skip
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top