Alex Stewart Alex Stewart - 2 months ago 6x
Python Question

new-line character seen in unquoted field

I have a file loaded in memory from a Django form. It is giving me the following error:

new-line character seen in unquoted field - do you need to open the file in universal-newline mode?

Another solution used this.

However, i already have the file in memory so i require to change it to opening in

This is my relevant code in

form = ResultsUploadForm(request.POST, request.FILES)
if form.is_valid():
reader = csv.reader(request.FILES['file'])
for row in reader:

Does anyone know how to go about fixing this? The error is thrown from this statement
for row in reader:


I found the solution in another post

The issue was how i was saving the .csv file. When producing a .csv file in excel for mac save it as "Windows Comma Separated Values (.csv)" This will stop the addition of unwanted characters that throw of import csv in Django and python.