1

I have many Python scripts that output CSV files. It is occasionally convenient to open these files in Excel. After installing OS X Mavericks, Excel no longer opens these files properly: Excel doesn't parse the files and it duplicates the rows of the file until it runs out of memory. Specifically, when Excel attempts to open the file, a prompt appears that reads: "File not loaded completely."

Example of code I'm using to generate the CSV files:

import csv
with open('csv_test.csv', 'wb') as f:
writer = csv.writer(f)
writer.writerow([1,2,3])
writer.writerow([4,5,6])

Even the simple file generated by the above code fails to load properly in Excel. However, if I open the CSV file in a text editor and copy/paste the text into Excel, parse it with text to columns, and then save as CSV from Excel, then I can reopen the CSV file in Excel without issue. Do I need to pass an additional parameter in my scripts to make Excel parse the CSV files the same way it used to? Or is there some setting I can change in OS X Mavericks or Excel? Thanks.

1
  • Excel tends to be specific about what kind of format it expects in regards to CSV. Maybe some character (like a BOM for Unicode) is mixing up Excel. Have you tried to import it as a text file to see if the problem isn't just about CSV recog? Oct 26, 2013 at 22:32

1 Answer 1

1

Compare two identical csv files, one made by python as shown above, and a supposedly identical one made by excel.

Use the diff utility from a terminal window;

diff -u python.csv excel.csv

That should show you the difference between the files.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .