コード例 #1
0
    def read_sheet(self, native_sheet):
        content = self.zipfile.read(native_sheet.payload)
        if PY2:
            sheet = StringIO(content)
        else:
            sheet = StringIO(content.decode("utf-8"))

        reader = CSVinMemoryReader(NamedContent(native_sheet.name, sheet),
                                   **self._keywords)
        return reader.to_array()
コード例 #2
0
ファイル: csvz.py プロジェクト: BenOussama180/pfe
    def read_sheet(self, index):
        name = self.content_array[index].name
        content = self.zipfile.read(self.content_array[index].payload)
        encoding_guess = chardet.detect(content)
        sheet = StringIO(content.decode(encoding_guess["encoding"]))

        return CSVinMemoryReader(NamedContent(name, sheet), **self.keywords)
コード例 #3
0
def test_writer_csvz_data_from_memory():
    if not PY2:
        io = StringIO()
        writer = get_writer(io, file_type="csvz")
        writer.write({"adb": [[2, 3]]})
    else:
        raise Exception("pass it")
コード例 #4
0
ファイル: test_io.py プロジェクト: netpastor/pyexcel-io
def test_writer_csvz_data_from_memory():
    if not PY2:
        io = StringIO()
        writer = get_writer(io, file_type="csvz")
        writer.write({'adb': [[2, 3]]})
    else:
        raise NotImplementedError("pass it")
コード例 #5
0
ファイル: csvz.py プロジェクト: Jerry0520/SeManager
 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)
コード例 #6
0
ファイル: test_csv_book.py プロジェクト: niejn/pyexcel-io
def test_utf16_memory_encoding():
    content = [[u'Äkkilähdöt', u'Matkakirjoituksia', u'Matkatoimistot']]
    io = StringIO()
    writer = CSVMemoryWriter(io,
                             None,
                             lineterminator="\n",
                             single_sheet_in_book=True,
                             encoding="utf-16")
    writer.write_array(content)
    actual = io.getvalue()
    if PY2:
        actual = actual.decode('utf-16')
    eq_(actual, u'Äkkilähdöt,Matkakirjoituksia,Matkatoimistot\n')
コード例 #7
0
ファイル: manager.py プロジェクト: readflybird/pyexcel-io
def get_io(file_type):
    """A utility function to help you generate a correct io stream

    :param file_type: a supported file type
    :returns: a appropriate io stream, None otherwise
    """
    __file_type = None
    if file_type:
        __file_type = file_type.lower()

    if __file_type in text_stream_types:
        return StringIO()
    elif __file_type in binary_stream_types:
        return BytesIO()
    else:
        return None
コード例 #8
0
ファイル: manager.py プロジェクト: Jerry0520/SeManager
def get_io(file_type):
    """A utility function to help you generate a correct io stream

    :param file_type: a supported file type
    :returns: a appropriate io stream, None otherwise
    """
    __file_type = None
    if file_type:
        __file_type = file_type.lower()

    if __file_type in TEXT_STREAM_TYPES:
        return StringIO()
    elif __file_type in BINARY_STREAM_TYPES:
        return BytesIO()
    else:
        return None
コード例 #9
0
 def set_sheet_name(self, name):
     self.content = StringIO()
     self.writer = csv.writer(self.content, **self._keywords)
コード例 #10
0
ファイル: csvz_sheet.py プロジェクト: BenOussama180/pfe
 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)
コード例 #11
0
def test_load_csvz_data_from_memory():
    if not PY2:
        io = StringIO()
        get_data(io, file_type="csvz")
    else:
        raise BadZipfile("pass it")