How can i add encoding to the python generated CSV file
- by user1958218
I am following this post
http://stackoverflow.com/a/9016545
and i want to know that how can i do that in Python. I don't know how can i insert BOM data in there
This is my current code
response = HttpResponse(content_type='text/csv')
response['Content-Type'] = 'application/octet-stream'
response['Content-Disposition'] = 'attachment; filename="results.csv"'
writer = UnicodeWriter(response, quoting=csv.QUOTE_ALL, encoding="utf-8")
I want to convert to utf -16 . BOm data is this but don't know how to insert it
From here http://stackoverflow.com/a/4440143
echo "\xEF\xBB\xBF"; // UTF-8 BOM
But i want it for python and utf-16
I tried opening that csv in notepad and insert \xef\xbb\xb in beginning and excel displayed that correctly. But it is also visible before first column.
How can i hide that because user wont like that