Answer the question
In order to leave comments, you need to log in
How to solve utf8 decoding issue when exporting CSV from Django?
I'm using Python 2.7
When uploading a CSV file, there is a problem of the following nature: the data in the file is encoded. (see screenshot)
My code:
for user in users:
result = user[0].encode('utf-8')
for x in filter(lambda q: q is not None, user):
result += ', '
if type(x) in (str, unicode):
result += x.encode('utf-8')
else:
result += str(x)
print type(result), result
writer.writerow(result)
return response
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question