Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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.

share|improve this question
    
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? –  Doktoro Reichard Oct 26 '13 at 22:32
add comment

1 Answer

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.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.