0

I have problems reading a CSV file generated by Excel. The code reading the file is very simple and it works ok with CSV files generated by hand:

file = request.FILES['organisations']
data = csv.reader(file, dialect='excel', delimiter=',', quotechar='"')

for line in data :
    ...

However, I get the following error pointing to that last line when I try to upload an Excel CSV file:

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

I've been Googling around but haven't been able to find something useful. Any help is appreciated!

aldo_vw
  • 608
  • 6
  • 17
  • possible duplicate of [open the file in universal-newline mode using csv module django](http://stackoverflow.com/questions/6726953/open-the-file-in-universal-newline-mode-using-csv-module-django) – Bleeding Fingers Dec 31 '13 at 19:24
  • I honestly can't see how that answer applies to this problem. If possible, please explain. Thank you. – aldo_vw Dec 31 '13 at 19:49

1 Answers1

0

Update this line:

data = csv.reader(StringIO.StringIO(file.read()), dialect='excel', delimiter=',', quotechar='"')
Goin
  • 3,856
  • 26
  • 44
  • Unfortunately it didn't work. I get the error: 'builtin_function_or_method' object has no attribute 'StringIO' – aldo_vw Dec 31 '13 at 19:37