[New-bugs-announce] [issue33844] Writing capital letters with csvwriter.writerow changes the csv file format

Stefan Vasilev report at bugs.python.org
Tue Jun 12 09:01:04 EDT 2018


New submission from Stefan Vasilev <sopata at iris.ai>:

import csv
csv.writer(open('./file.csv', 'a', newline='')).writerow(['ID', 0])

If you try to open file.csv with Excel on Windows 10 it says:
The file format and extension of 'file.csv' don't match. The file could be corrupted or unsafe. Unless you trust its source don't open it. Do you want to open it anyway.

When you click 'Yes', another msgbox appears saying:
Excel has detected that 'file.csv' is a SYLK file, but cannot load it. Either the file has errors or it is not a SYLK fyle format. Click OK to try to open the file in a different format.

When you click on 'OK' it opens it as expected.

The strange thing is that if you use the following code, there are no problems opening it:
import csv
csv.writer(open('./file.csv', 'a', newline='')).writerow(['Id', 0])

----------
components: Windows
messages: 319378
nosy: Stefan Vasilev, paul.moore, steve.dower, tim.golden, zach.ware
priority: normal
severity: normal
status: open
title: Writing capital letters with csvwriter.writerow changes the csv file format
type: behavior
versions: Python 3.5

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue33844>
_______________________________________


More information about the New-bugs-announce mailing list