extra rows in a CSV module output when viewed in excel 2007
MRAB
python at mrabarnett.plus.com
Thu Aug 19 20:10:29 EDT 2010
JonathanB wrote:
> On Aug 13, 3:52 pm, alex23 <wuwe... at gmail.com> wrote:
>> On Aug 13, 4:22 pm, JonathanB <doulo... at gmail.com> wrote:
>>
>>> writer = csv.writer(open(output, 'w'), dialect='excel')
>> I think - not able to test atm - that if you open the file in 'wb'
>> mode instead it should be fine.
>
> changed that to
> writer = csv.writer(open(output,'wb'),dialect='excel')
>
> Now I get this error:
>
> TypeError: must be bytes or buffer, not str
>
> I'm using Python 3.1, maybe that changes things?
You want to open the file in text mode, but not write Windows line
endings (CRLF) for each newline:
writer = csv.writer(open(output, 'w', newline=''), dialect='excel')
More information about the Python-list
mailing list