How to use the pyexcel.SeriesReader function in pyexcel

To help you get started, we’ve selected a few pyexcel examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github pyexcel / pyexcel / tests / test_sheet_update.py View on Github external
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.SeriesReader
        self.testfile = "testcsv.xls"
        create_sample_file1_series(self.testfile)
github pyexcel / pyexcel / tests / test_meta_coding.py View on Github external
def test_merge_two_files(self):
        merged = pyexcel.cookbook.SHEET(self.testfile) + pyexcel.cookbook.SHEET(self.testfile2)
        r = pyexcel.SeriesReader(merged)
        data = pyexcel.utils.to_dict(r)
        content = {}
        content.update(self.content)
        content.update(self.content2)
        assert data == content
        try:
            pyexcel.cookbook.merge_two_files(self.testfile, self.testfile2)
            assert 1==2
        except NotImplementedError:
            assert 1==1
github pyexcel / pyexcel / tests / test_reader.py View on Github external
def test_headers(self):
        r = p.SeriesReader(self.testfile, series=4)
        actual = r.colnames
        eq_(self.content[4], actual)
github pyexcel / pyexcel / tests / test_writer.py View on Github external
def test_write_series_reader(self):
        r = pe.SeriesReader(self.testfile)
        w = pe.Writer(self.testfile2)
        w.write_reader(r)
        w.close()
        r2 = pe.SeriesReader(self.testfile2)
        content = pe.utils.to_dict(r2)
        assert content == self.content
github pyexcel / pyexcel / tests / test_meta_coding.py View on Github external
def _test_update_columns(self):
        bad_column = {"A": [31, 1, 1, 1, 1]}
        custom_column = {"Z": [33, 44, 55, 66, 77]}
        try:
            # try non-existent column first
            pyexcel.cookbook.update_columns(self.testfile, bad_column)
            assert 1==2
        except IndexError:
            assert 1==1
        pyexcel.cookbook.update_columns(self.testfile, custom_column)
        r = pyexcel.SeriesReader("pyexcel_%s" % self.testfile)
        data = pyexcel.utils.to_dict(r)
        assert data["Z"] == custom_column["Z"]
        try:
            pyexcel.cookbook.update_columns(self.testfile, custom_column)
            r = pyexcel.SeriesReader("pyexcel_%s" % self.testfile)
            assert 1==2
        except NotImplementedError:
            assert 1==1
        pyexcel.cookbook.update_columns(self.testfile, custom_column, "test4.ods")
        r = pyexcel.SeriesReader("test4.ods")
        data = pyexcel.utils.to_dict(r)
        assert data["Z"] == custom_column["Z"]
github pyexcel / pyexcel / tests / test_reader.py View on Github external
def test_headers(self):
        r = p.SeriesReader(self.testfile)
        actual = r.colnames
        assert self.content[0] == actual
github pyexcel / pyexcel / tests / test_cookbook.py View on Github external
def test_merge_readers(self):
        r1 = pe.SeriesReader(self.testfile)
        r2 = pe.SeriesReader(self.testfile2)
        r3 = pe.SeriesReader(self.testfile3)
        file_array = [r1, r2, r3]
        pe.cookbook.merge_readers(file_array)
        r = pe.SeriesReader("pyexcel_merged.csv")
        r.format(int)
        content = {}
        content.update(self.content)
        content.update(self.content2)
        content.update(self.content3)
        eq_(r.dict, content)
        pe.cookbook.merge_readers(file_array)  # bang, do not overwrite
github pyexcel / pyexcel / tests / test_meta_coding.py View on Github external
pyexcel.cookbook.update_columns(self.testfile, bad_column)
            assert 1==2
        except IndexError:
            assert 1==1
        pyexcel.cookbook.update_columns(self.testfile, custom_column)
        r = pyexcel.SeriesReader("pyexcel_%s" % self.testfile)
        data = pyexcel.utils.to_dict(r)
        assert data["Z"] == custom_column["Z"]
        try:
            pyexcel.cookbook.update_columns(self.testfile, custom_column)
            r = pyexcel.SeriesReader("pyexcel_%s" % self.testfile)
            assert 1==2
        except NotImplementedError:
            assert 1==1
        pyexcel.cookbook.update_columns(self.testfile, custom_column, "test4.ods")
        r = pyexcel.SeriesReader("test4.ods")
        data = pyexcel.utils.to_dict(r)
        assert data["Z"] == custom_column["Z"]
github pyexcel / pyexcel / tests / test_cookbook.py View on Github external
def test_merge_readers(self):
        r1 = pe.SeriesReader(self.testfile)
        r2 = pe.SeriesReader(self.testfile2)
        r3 = pe.SeriesReader(self.testfile3)
        file_array = [r1, r2, r3]
        pe.cookbook.merge_readers(file_array)
        r = pe.SeriesReader("pyexcel_merged.csv")
        r.format(int)
        content = {}
        content.update(self.content)
        content.update(self.content2)
        content.update(self.content3)
        eq_(r.dict, content)
        pe.cookbook.merge_readers(file_array)  # bang, do not overwrite
github pyexcel / pyexcel / examples / example_usage_of_internal_apis / simple_usage / series.py View on Github external
def main(base_dir):
    # print all in json
    #
    # Column 1 Column 2 Column 3
    # 1        4        7
    # 2        5        8
    # 3        6        9
    reader = SeriesReader(os.path.join(base_dir,"example_series.ods"))
    data = to_dict(reader)
    print(json.dumps(data))
    # output:
    # {"Column 2": [4.0, 5.0, 6.0], "Column 3": [7.0, 8.0, 9.0], "Column 1": [1.0, 2.0, 3.0]}
    
    # get the column headers
    print(reader.colnames)
    # [u'Column 1', u'Column 2', u'Column 3']
    
    # get the content in one dimensional array
    data = to_array(reader.enumerate())
    print(data)
    # [1.0, 4.0, 7.0, 2.0, 5.0, 8.0, 3.0, 6.0, 9.0]
    
    # get the content in one dimensional array
    # in reverse order