[issue7198] Extraneous newlines with csv.writer on Windows

Skip Montanaro report at bugs.python.org
Wed Jul 28 19:19:38 CEST 2010


Skip Montanaro <skip at pobox.com> added the comment:

I got access to Python 2.6.5 on Windows and ran this simple
example:

Python 2.6.5 (r265:79096, Mar 19 2010, 21:48:26) [MSC v.1500 32 bit (Intel)] on win32
Type "copyright", "credits" or "license()" for more information.

    ****************************************************************
    Personal firewall software may warn about the connection IDLE
    makes to its subprocess using this computer's internal loopback
    interface.  This connection is not visible on any external
    interface and no data is sent to or received from the Internet.
    ****************************************************************
    
IDLE 2.6.5      
>>> f = open("H:sample.csv", "wb")
>>> import csv
>>> writer = csv.writer(f)
>>> writer.writerow([1,2,3])
>>> writer.writerow(['a', 'b', 'c'])
>>> del writer
>>> f.close()
>>> 

I then looked at the CSV file which it generated.
Looked find to me.  Each of the two rows was terminated
by a single CRLF pair.

Then I repeated the "test", opening the file in text
mode:

>>> f = open("H:sample2.csv", "w")

>>> writer = csv.writer(f)

>>> writer.writerow([1,2,3])

>>> writer.writerow(['a', 'b', 'c'])

>>> del writer

>>> f.close()

>>> 

That output does indeed terminate each line with
CRCRLF and when viewed in a spreadsheet program
such as OpenOffice Calc (probably Excel as well),
displays a blank line between the 123 row and the
abc row.

I've removed the "unit test needed" attribute from the
ticket as there is a test_writerows test case in the
Python test suite.  Also closing again and marking
invalid.  If you still believe there is actually a
problem, feel free to reopen this issue, but also
please send me (skip at pobox.com) a short example and
the erroneous output it produces for you (attach your
two files - don't just embed them in your mail msg).

----------
resolution:  -> invalid
stage: unit test needed -> 
status: open -> closed

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue7198>
_______________________________________


More information about the Python-bugs-list mailing list