[ python-Bugs-944890 ] csv writer bug on windows

SourceForge.net noreply at sourceforge.net
Thu Apr 29 17:06:30 EDT 2004


Bugs item #944890, was opened at 2004-04-29 17:06
Message generated for change (Tracker Item Submitted) made by Item Submitter
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: Nobody/Anonymous (nobody)
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.

----------------------------------------------------------------------

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