I have a model: (Python 3.5)
class Model(models.Model):
import_file = models.FileField(upload_to="import")
def save(self, *args, **kwargs):
super(Model, self).save(*args, **kwargs)
with open(self.import_file.name) as csvfile:
reader = DictReader(csvfile, dialect='excel')
for line in reader:
print (line)
I got
'utf-8' codec can't decode byte 0x95 in position 15: invalid start byte
The string that could not be encoded/decoded was: !f�}
I tried with utf16, but then I got error with BOM.
Do you guys have any ideas?
EDIT1 I've just tried
...
with open(self.import_file.name, encoding='utf-8') as csvfile:
...
Still same error:
'utf-8' codec can't decode byte 0x95 in position 15: invalid start byte
EDIT2
If I changed encoding to ISO-8859-1 I got:
line contains NULL byte