Ich versuche, auf eine model.filefieldin Django zuzugreifen , um eine CSV- Datei in Python mit dem csvModul zu analysieren . Es funktioniert unter Windows, aber auf dem Mac gab es mir Folgendes:
Exception Type: Error
Exception Value: new-line character seen in unquoted field - do you need to open the file in universal-newline mode?
Dies ist der Code:
myfile = customerbulk.objects.all()[0].fileup
mydata = csv.reader(myfile)
for email,mobile,name,civilid in mydata:
print email,mobile,name,civilid
rU(Sie hängt mit der Funktion open () zusammen und ist nicht csv-spezifisch.): In addition to the standard fopen() values mode may be 'U' or 'rU'. Python is usually built with universal newlines support; supplying 'U' opens the file as a text file, but lines may be terminated by any of the following: the Unix end-of-line convention '\n', the Macintosh convention '\r', or the Windows convention '\r\n'. Docs.python.org/2/library/functions.html#open
newline=''anstelle von mode='U'.
customerbulk.objects.all()[0].fileupDing? Ist es ein Dateiname auf einem Modell?