예제 #1
0
class CSVZipSheetWriter(CSVSheetWriter):
    def __init__(self, zipfile, sheetname, file_extension, **keywords):
        self.file_extension = file_extension
        keywords['single_sheet_in_book'] = False
        CSVSheetWriter.__init__(self, zipfile, sheetname, **keywords)

    def set_sheet_name(self, name):
        self.content = StringIO()
        self.writer = csv.writer(self.content, **self._keywords)

    def close(self):
        file_name = "%s.%s" % (self._native_sheet, self.file_extension)
        self.content.seek(0)
        self._native_book.writestr(file_name, self.content.read())
        self.content.close()
예제 #2
0
class CSVZipSheetWriter(CSVFileWriter):
    """ handle the zipfile interface """
    def __init__(self, zipfile, sheetname, file_extension, **keywords):
        self.file_extension = file_extension
        keywords["single_sheet_in_book"] = False
        self.content = StringIO()
        super().__init__(zipfile, sheetname, **keywords)

    def get_writer(self):
        return csv.writer(self.content, **self._keywords)

    def close(self):
        file_name = "%s.%s" % (self._sheet_name, self.file_extension)
        self.content.seek(0)
        self._native_book.writestr(file_name, self.content.read())
        self.content.close()
예제 #3
0
파일: csvz.py 프로젝트: Jerry0520/SeManager
class CSVZipSheetWriter(CSVSheetWriter):
    """ handle the zipfile interface """
    def __init__(self, zipfile, sheetname, file_extension, **keywords):
        self.file_extension = file_extension
        keywords['single_sheet_in_book'] = False
        CSVSheetWriter.__init__(self, zipfile, sheetname, **keywords)

    def set_sheet_name(self, name):
        self.content = StringIO()
        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)
        self.content.seek(0)
        self._native_book.writestr(file_name, self.content.read())
        self.content.close()
예제 #4
0
파일: csvz.py 프로젝트: pyexcel/pyexcel-io
class CSVZipSheetWriter(CSVSheetWriter):
    """ handle the zipfile interface """

    def __init__(self, zipfile, sheetname, file_extension, **keywords):
        self.file_extension = file_extension
        keywords["single_sheet_in_book"] = False
        CSVSheetWriter.__init__(self, zipfile, sheetname, **keywords)

    def set_sheet_name(self, name):
        self.content = StringIO()
        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)
        self.content.seek(0)
        self._native_book.writestr(file_name, self.content.read())
        self.content.close()