Use utf8 encoding when downloading results as CSV
This commit is contained in:
parent
1b7612ffb0
commit
43472c7eb6
|
@ -27,6 +27,7 @@ Model Master View
|
||||||
from __future__ import unicode_literals, absolute_import
|
from __future__ import unicode_literals, absolute_import
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
import csv
|
||||||
import datetime
|
import datetime
|
||||||
import tempfile
|
import tempfile
|
||||||
import logging
|
import logging
|
||||||
|
@ -2720,8 +2721,13 @@ class MasterView(View):
|
||||||
results = results.with_session(session).all()
|
results = results.with_session(session).all()
|
||||||
fields = self.get_csv_fields()
|
fields = self.get_csv_fields()
|
||||||
|
|
||||||
csv_file = open(path, 'wt')
|
if six.PY2:
|
||||||
writer = UnicodeDictWriter(csv_file, fields)
|
csv_file = open(path, 'wb')
|
||||||
|
writer = UnicodeDictWriter(csv_file, fields, encoding='utf_8')
|
||||||
|
else: # PY3
|
||||||
|
csv_file = open(path, 'wt', encoding='utf_8')
|
||||||
|
writer = csv.DictWriter(csv_file, fields)
|
||||||
|
|
||||||
writer.writeheader()
|
writer.writeheader()
|
||||||
|
|
||||||
def write(obj, i):
|
def write(obj, i):
|
||||||
|
|
Loading…
Reference in a new issue