Estoy tratando de acceder a model.filefield
en Django para analizar un archivo CSV en Python usando el csv
módulo. Está funcionando en Windows, pero en Mac me dio esto:
Exception Type: Error
Exception Value: new-line character seen in unquoted field - do you need to open the file in universal-newline mode?
Este es el código:
myfile = customerbulk.objects.all()[0].fileup
mydata = csv.reader(myfile)
for email,mobile,name,civilid in mydata:
print email,mobile,name,civilid
customerbulk.objects.all()[0].fileup
cosa. ¿Es un nombre de archivo en un modelo?rU
(está relacionada con la función open () y no es específica de csv):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#opennewline=''
lugar demode='U'
.