slight csv misbehavior under Windows

Thomas Womack twomack at chiark.greenend.org.uk
Mon Aug 18 07:55:25 CEST 2003


I'm using the csv module in python 2.3 under Windows XP; it seems that
two separate mechanisms try to handle the perverse Windows habit of
ending lines with 0d0a, and so

writer = csv.writer(file('foo.csv','w'))
for i in thing:
  writer.write(i)

produces lines ending 0d0d0a, and when you load this into Excel 97 the
data appears double-spaced.

Opening the file with 'wb' solves the problem, but it would be lovely
were this either fixed or documented; it's rather unintuitive that a
file opened with 'wb' still ends lines with 0d0a.

Please tell me if this is not the appropriate place to make this kind
of bug report.

Tom




More information about the Python-list mailing list