def setUp(self):
        """
        Make a test csv file as:

        a,b,c,d
        e,f,g,h
        i,j,1.1,1
        """
        self.testfile = "testcsv.csv"
        create_sample_file1(self.testfile)
Example #2
0
    def setUp(self):
        """
        Make a test csv file as:

        a,b,c,d
        e,f,g,h
        i,j,1.1,1
        """
        self.testfile = "testcsv.csv"
        create_sample_file1(self.testfile)
Example #3
0
 def test_csv_stringio(self):
     csvfile = "cute.csv"
     create_sample_file1(csvfile)
     with open(csvfile, "r") as f:
         content = f.read()
         r = pe.Reader(("csv", content))
         result=['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 1.1, 1]
         actual = pe.utils.to_array(r.enumerate())
         assert result == actual
     if os.path.exists(csvfile):
         os.unlink(csvfile)
Example #4
0
 def test_ods_stringio(self):
     odsfile = "cute.xlsx"
     create_sample_file1(odsfile)
     with open(odsfile, "rb") as f:
         content = f.read()
         r = pyexcel.get_sheet(file_type="xlsx", file_content=content)
         result=['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 1.1, 1]
         actual = pyexcel.utils.to_array(r.enumerate())
         assert result == actual
     if os.path.exists(odsfile):
         os.unlink(odsfile)
Example #5
0
 def test_book_stringio(self):
     csvfile = "cute.xls"
     create_sample_file1(csvfile)
     with open(csvfile, "rb") as f:
         content = f.read()
         b = pe.load_book_from_memory("xls", content)
         result = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 1.1, 1]
         actual = pe.utils.to_array(b[0].enumerate())
         assert result == actual
     if os.path.exists(csvfile):
         os.unlink(csvfile)
Example #6
0
    def setUp(self):
        """
        Make a test csv file as:

        a,b,c,d
        e,f,g,h
        i,j,k,l
        """
        self.testfile = "testcsv.csv"
        self.rows = 3
        create_sample_file1(self.testfile)
Example #7
0
 def test_ods_stringio(self):
     odsfile = "cute.xlsx"
     create_sample_file1(odsfile)
     with open(odsfile, "rb") as f:
         content = f.read()
         r = pyexcel.Reader(("xlsx", content))
         result=['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 1.1, 1]
         actual = pyexcel.utils.to_array(r.enumerate())
         assert result == actual
     if os.path.exists(odsfile):
         os.unlink(odsfile)
Example #8
0
    def setUp(self):
        """
        Make a test csv file as:

        a,b,c,d
        e,f,g,h
        i,j,1.1,1
        """
        self.testclass = pe.Reader
        self.testfile = "testcsv.xls"
        create_sample_file1(self.testfile)
Example #9
0
 def test_book_stringio(self):
     csvfile = "cute.xls"
     create_sample_file1(csvfile)
     with open(csvfile, "rb") as f:
         content = f.read()
         b = pe.load_book_from_memory("xls", content)
         result=['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 1.1, 1]
         actual = pe.utils.to_array(b[0].enumerate())
         assert result == actual
     if os.path.exists(csvfile):
         os.unlink(csvfile)
Example #10
0
 def test_csvz_stringio(self):
     csvfile = "cute.csvz"
     create_sample_file1(csvfile)
     with open(csvfile, "rb") as f:
         content = f.read()
         r = pe.load_from_memory("csvz", content)
         result=['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', '1.1', '1']
         actual = pe.utils.to_array(r.enumerate())
         assert result == actual
     if os.path.exists(csvfile):
         os.unlink(csvfile)
Example #11
0
 def test_ods_stringio(self):
     odsfile = "cute.xlsx"
     create_sample_file1(odsfile)
     with open(odsfile, "rb") as f:
         content = f.read()
         r = pyexcel.get_sheet(file_type="xlsx", file_content=content)
         result = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", 1.1, 1]
         actual = list(r.enumerate())
         eq_(result, actual)
     if os.path.exists(odsfile):
         os.unlink(odsfile)
 def test_ods_stringio(self):
     odsfile = "cute.ods"
     create_sample_file1(odsfile)
     with open(odsfile, "rb") as f:
         content = f.read()
         r = pyexcel.get_sheet(file_type="ods", file_content=content)
         result = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 1.1, 1]
         actual = list(r.enumerate())
         eq_(result, actual)
     if os.path.exists(odsfile):
         os.unlink(odsfile)
Example #13
0
 def test_xls_stringio(self):
     csvfile = "cute.xls"
     create_sample_file1(csvfile)
     with open(csvfile, "rb") as f:
         content = f.read()
         r = pe.Reader(("xls", content))
         result = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 1.1, 1]
         actual = pe.utils.to_array(r.enumerate())
         assert result == actual
     if os.path.exists(csvfile):
         os.unlink(csvfile)
Example #14
0
    def setUp(self):
        """
        Make a test csv file as:

        a,b,c,d
        e,f,g,h
        i,j,1.1,1
        """
        self.testclass = pe.Reader
        self.testfile = "testcsv.xls"
        create_sample_file1(self.testfile)
Example #15
0
 def test_xls_stringio(self):
     testfile = "cute.xls"
     create_sample_file1(testfile)
     with open(testfile, "rb") as f:
         content = f.read()
         r = pyexcel.get_sheet(file_type="xls", file_content=content)
         result = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 1.1, 1]
         actual = list(r.enumerate())
         eq_(result, actual)
     if os.path.exists(testfile):
         os.unlink(testfile)
Example #16
0
 def test_xls_stringio(self):
     xlsfile = "cute.xls"
     create_sample_file1(xlsfile)
     with open(xlsfile, "rb") as f:
         content = f.read()
         r = pyexcel.get_sheet(file_type="xls", file_content=content)
         result = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 1.1, 1]
         actual = pyexcel.utils.to_array(r.enumerate())
         assert result == actual
     if os.path.exists(xlsfile):
         os.unlink(xlsfile)
Example #17
0
    def setUp(self):
        """
        Make a test csv file as:

        a,b,c,d
        e,f,g,h
        i,j,1.1,1
        """
        self.testclass = pyexcel.PlainReader
        self.testfile = "testcsv.csv"
        self.rows = 3
        create_sample_file1(self.testfile)
Example #18
0
 def test_xlsx_stringio(self):
     testfile = "cute.xlsx"
     create_sample_file1(testfile)
     with open(testfile, "rb") as f:
         content = f.read()
         r = pyexcel.get_sheet(
             file_type="xlsx", file_content=content, library="pyexcel-xlsx"
         )
         result = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", 1.1, 1]
         actual = list(r.enumerate())
         eq_(result, actual)
     if os.path.exists(testfile):
         os.unlink(testfile)
Example #19
0
 def test_csvz_stringio(self):
     csvfile = "cute.csvz"
     create_sample_file1(csvfile)
     with open(csvfile, "rb") as f:
         content = f.read()
         r = pe.load_from_memory("csvz", content)
         result = [
             'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', '1.1', '1'
         ]
         actual = pe.utils.to_array(r.enumerate())
         assert result == actual
     if os.path.exists(csvfile):
         os.unlink(csvfile)
Example #20
0
def do_book_read_stringio(file_name):
    create_sample_file1(file_name)
    file_type = file_name.split(".")[-1]
    open_flag = "rb"
    if file_type in ["csv", "tsv"]:
        open_flag = "r"
    with open(file_name, open_flag) as f:
        content = f.read()
        b = pe.get_book(file_type=file_type, file_content=content)
        result = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", 1.1, 1]
        actual = list(b[0].enumerate())
        eq_(result, actual)
    if os.path.exists(file_name):
        os.unlink(file_name)
Example #21
0
def do_read_stringio(file_name):
    create_sample_file1(file_name)
    file_type = file_name.split('.')[-1]
    open_flag = 'rb'
    if file_type in ['csv', 'tsv']:
        open_flag = 'r'
    with open(file_name, open_flag) as f:
        content = f.read()
        r = pe.get_sheet(file_type=file_type, file_content=content)
        result=['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 1.1, 1]
        actual = pe.utils.to_array(r.enumerate())
        assert result == actual
    if os.path.exists(file_name):
        os.unlink(file_name)
Example #22
0
def do_read_stringio(file_name):
    create_sample_file1(file_name)
    file_type = file_name.split('.')[-1]
    open_flag = 'rb'
    if file_type in ['csv', 'tsv']:
        open_flag = 'r'
    with open(file_name, open_flag) as f:
        content = f.read()
        r = pe.get_sheet(file_type=file_type, file_content=content)
        result = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 1.1, 1]
        actual = pe.utils.to_array(r.enumerate())
        assert result == actual
    if os.path.exists(file_name):
        os.unlink(file_name)
Example #23
0
def do_book_read_stringio(file_name):
    create_sample_file1(file_name)
    file_type = file_name.split('.')[-1]
    open_flag = 'rb'
    if file_type in ['csv', 'tsv']:
        open_flag = 'r'
    with open(file_name, open_flag) as f:
        content = f.read()
        b = pe.get_book(file_type=file_type, file_content=content)
        result = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 1.1, 1]
        actual = list(b[0].enumerate())
        eq_(result, actual)
    if os.path.exists(file_name):
        os.unlink(file_name)