2

I was trying to get an idea of some lines in a huge csv file so I did this

with open('###.csv','rb')` as csvfile: conusreader = csv.reader(csvfile,delimiter=' ', quotechar='|') for row in conusreader: print ', '.join(row) 

Then I got an error in Pycharm

"for row in conusreader: _csv.Error: new-line character seen in unquoted field - do you need to open the file in universal-newline mode?"

I'm not quite sure what it means. Could anyone help me to fix this error?

6
  • 1
    Could you gave a small example of your csv file? Commented Jun 28, 2015 at 18:40
  • The error is implying you need to try using something like this: csv.reader(open(csvfile, 'rU'), delimeter=' ', quote='|'). Which operating system are you running this on? Commented Jun 28, 2015 at 19:19
  • Hi Martin. I use OS X Yosemite and IDE is Pycharm. a line of the file looks like this (geospatial data) "GA 13215 Muscogee County 1 Columbus -84.8769 32.51 250 -85.0262 32.608 -85.0228 32.6079 -85.0216 32.6079 -85.0154 32.6078 -84.9818 .......". Commented Jun 28, 2015 at 20:53
  • I tried what you wrote and got the same error... Commented Jun 28, 2015 at 20:53
  • Do you get any output or does this fail on the first loop? Consider loading the file into an editor to try and spot what is triggering the fault. Consider using a hex editor to spot 0x0D 0x0A characters in the csv file. Commented Jun 28, 2015 at 21:20

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.