示例#1
0
 def test_reading(self):
     data = [[1,2,3]]
     zipbook = CSVZipWriter(self.file)
     sheet = zipbook.create_sheet(None)
     sheet.write_array(data)
     sheet.close()
     zipbook.close()
     zipreader = CSVZipBook(self.file)
     data = zipreader.sheets()
     assert data['pyexcel_sheet1'] == [['1','2','3']]
示例#2
0
def test_reading_from_memory():
    data = [[1,2,3]]
    io = get_io("csvz")
    zipbook = CSVZipWriter(io)
    sheet = zipbook.create_sheet(None)
    sheet.write_array(data)
    sheet.close()
    zipbook.close()
    zipreader = CSVZipBook(io)
    data = zipreader.sheets()
    assert data['pyexcel_sheet1'] == [['1','2','3']]
示例#3
0
 def test_writing(self):
     data = [[1,2,3]]
     file_name = 'pyexcel_sheet1.tsv'
     zipbook = CSVZipWriter(self.file, dialect="excel-tab")
     sheet = zipbook.create_sheet(None)
     sheet.write_array(data)
     sheet.close()
     zipbook.close()
     self.zip = zipfile.ZipFile(self.file, 'r')
     assert self.zip.namelist() == [file_name]
     content = self.zip.read(file_name)
     if not PY2:
         content = content.decode('utf-8')
     assert content.replace('\r','').strip('\n') == "1\t2\t3"