Microsoft Excel SYLK error opening a CSV file

Today I ran into an interesting problem where I was trying to open a Python generated CSV file. Microsoft Excel gives a SYLK file error when trying to open the file. The confusing thing was that I’ve been using Python to generate CSV files for graphing and other Excel type work for a while now, and never run into this. What was more, it was repeatable.

Here is the actual error:

Excel has detected that ‘filename.csv’ is an SYLK file, but cannot load it. Either the file has error or it is not a SYLK file format. Click OK to try to open the file in a different format

Googling, I found the issue. Apparently Microsoft decided that, regardless of the file extension, they were going to look at the first bit of data in your file. If it started with ID, they were going to assume it was a SYLK file. What’s more, it seems that this has been an issue for a long time! I found one helpful site here that shows Microsoft Excel has been returning SYLK errors like this since January of 2012. That’s over seven years! Even more annoying was Microsoft’s insistence at ignoring the actual file extension.

I updated my Python script to call the first column of data something else and all was well again with the world. I did find out that it was literally anything that starts with capital ID. Lowercase (id) works just fine.