Pages

Tuesday, February 11, 2014

[Python] Dealing with the 'CSV new-line character seen in unquoted field error'

To load the Windows-imported csv files or any csv files which are generated via Excel without the error message:

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

Just do as it said: use universal-newline mode, which means ‘U’ in the arguments.

Example:
import csv fin = open(‘test.csv’, ‘rU’) myReader = csv.reader(fin, delimiter = ‘,’)

No comments:

Post a Comment