I manage to upload a csv file using the following code:
def _parse_csv(self):
"""
:return: list of dict from csv file (line/rows)
"""
csv_file = tempfile.TemporaryFile('w+') csv_file.write(self.filebuffer) csv_file.seek(0) # this will send you to the beginning of the file
reader = UnicodeDictReader(csv_file , fieldnames=self.fieldnames)
return list(reader)
Can't do the same with xls as file is open inside xlrd.open_workbook method.
Hello:
I manage to upload a csv file using the following code:
def _parse_csv(self): TemporaryFile( 'w+')
csv_file. write(self. filebuffer)
csv_file. seek(0) # this will send you to the beginning of the file er(csv_ file , fieldnames= self.fieldnames )
"""
:return: list of dict from csv file (line/rows)
"""
csv_file = tempfile.
reader = UnicodeDictRead
return list(reader)
Can't do the same with xls as file is open inside xlrd.open_workbook method.
Hope this help.
Mayte