2

I created a csv file in Mac Excel and wanna upload it to my server through Django, part of my code in views.py is as follows:

 FILE_UPLOAD_DIR2 = '/mnt/opt/data/spam/' fd2, filepath2 = tempfile.mkstemp(suffix=request.FILES['spamFile'].name, dir=FILE_UPLOAD_DIR2) with open(filepath2, 'wb') as dest2: shutil.copyfileobj(request.FILES['spamFile'], dest2) 

But an unexpected error came out: new-line character seen in unquoted field - do you need to open the file in universal-newline mode?

I uploaded a csv file created in Windows to my server before and it worked fine, So I guess this may have something to do with the difference of the csv file created in Windows and Mac. Someone has the same problem before?

1
  • wait I don't get it, what was the problem? can you say this explicitly? Commented Jul 5, 2016 at 16:32

1 Answer 1

8

I had the exact same issue! It had to do with the way it is saved on a mac! Resave your csv and scroll down and you should see two other kinds of .csv files you can save it as.

Save it under the windows version and it will now be read fine!!

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.