💚 limit the UnicodeWriter to python 2 only, #44
This commit is contained in:
parent
c5656ac5a8
commit
2c539ecf1f
|
@ -35,8 +35,7 @@ class UnicodeWriter(object):
|
|||
for s in row])
|
||||
# Fetch UTF-8 output from the queue ...
|
||||
data = self.queue.getvalue()
|
||||
if compact.PY2:
|
||||
data = data.decode("utf-8")
|
||||
data = data.decode("utf-8")
|
||||
# ... and reencode it into the target encoding
|
||||
data = self.encoder.encode(data)
|
||||
# write to the target stream
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
"""
|
||||
import zipfile
|
||||
|
||||
from pyexcel_io._compact import StringIO
|
||||
from pyexcel_io._compact import StringIO, PY2
|
||||
from pyexcel_io.book import BookWriter
|
||||
from pyexcel_io.constants import DEFAULT_SHEET_NAME, FILE_FORMAT_CSVZ
|
||||
|
||||
|
@ -25,11 +25,15 @@ class CSVZipSheetWriter(CSVSheetWriter):
|
|||
|
||||
def set_sheet_name(self, name):
|
||||
self.content = StringIO()
|
||||
self.writer = UnicodeWriter(
|
||||
self.content,
|
||||
encoding=self._encoding,
|
||||
**self._keywords
|
||||
)
|
||||
if PY2:
|
||||
self.writer = UnicodeWriter(
|
||||
self.content,
|
||||
encoding=self._encoding,
|
||||
**self._keywords
|
||||
)
|
||||
else:
|
||||
import csv
|
||||
self.writer = csv.writer(self.content, **self._keywords)
|
||||
|
||||
def close(self):
|
||||
file_name = "%s.%s" % (self._native_sheet, self.file_extension)
|
||||
|
|
Loading…
Reference in New Issue