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]) |