[ python-Bugs-944890 ] csv writer bug on windows
SourceForge.net
noreply at sourceforge.net
Sat Jun 5 12:14:43 EDT 2004
Bugs item #944890, was opened at 2004-04-29 17:06
Message generated for change (Comment added) made by tim_one
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=944890&group_id=5470
Category: None
Group: None
Status: Open
Resolution: None
Priority: 5
Submitted By: Brian Kelley (wc2so1)
Assigned to: Skip Montanaro (montanaro)
Summary: csv writer bug on windows
Initial Comment:
The excel dialect is set up to be
class excel(Dialect):
delimiter = ','
quotechar = '"'
doublequote = True
skipinitialspace = False
lineterminator = '\r\n'
quoting = QUOTE_MINIMAL
register_dialect("excel", excel)
However, on the windows platform, the lineterminator
should be simply "\n"
My suggested fix is:
class excel(Dialect):
delimiter = ','
quotechar = '"'
doublequote = True
skipinitialspace = False
if sys.platform == "win32":
lineterminator = '\n'
else:
lineterminator = '\r\n'
quoting = QUOTE_MINIMAL
Which seems to work. It could be that I'm missing
something, but the universal readlines doesn't appear
to work for writing files. If this is a usage issue,
it probably should be a documentation fix.
----------------------------------------------------------------------
>Comment By: Tim Peters (tim_one)
Date: 2004-06-05 12:14
Message:
Logged In: YES
user_id=31435
Excel on Windows puts \r\n line ends in .csv files it creates (I
just tried it). Since the OP mentioned "universal readlines", I
bet he's opening the file with "U" (but it needs to be "rb").
----------------------------------------------------------------------
Comment By: Skip Montanaro (montanaro)
Date: 2004-06-05 12:04
Message:
Logged In: YES
user_id=44345
Can you attach an example that fails? I don't have access
to Windows. Note that you must open the file with binary
mode ("wb" or "rb").
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=944890&group_id=5470
More information about the Python-bugs-list
mailing list