How to use the pyexcel.load 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_filter.py View on Github external
def test_even_row_filter(self):
        r = pe.load((self.file_type, self.testfile.getvalue()))
        r.filter(pe.sheets.filters.EvenRowFilter())
        assert r.number_of_rows() == 2
        assert r.number_of_columns() == 4
        result = [1, 2, 3, 4, 9, 10, 11, 12]
        actual = list(r.enumerate())
        eq_(result, actual)
github pyexcel / pyexcel / tests / test_filter.py View on Github external
def test_odd_row_filter(self):
        r = pe.load((self.file_type, self.testfile.getvalue()))
        r.filter(pe.sheets.filters.OddRowFilter())
        assert r.number_of_rows() == 1
        assert r.number_of_columns() == 4
        result = [5, 6, 7, 8]
        actual = list(r.enumerate())
        eq_(result, actual)
github pyexcel / pyexcel / tests / test_filter.py View on Github external
r.filter(pe.sheets.filters.ColumnFilter([0, 2]))
        assert r.number_of_rows() == 3
        assert r.number_of_columns() == 2
        result = [2, 4, 6, 8, 10, 12]
        actual = list(r.enumerate())
        eq_(result, actual)
        # filter out last column and first column
        r = pe.load((self.file_type, self.testfile.getvalue()))
        r.filter(pe.sheets.filters.ColumnFilter([0, 3]))
        assert r.number_of_rows() == 3
        assert r.number_of_columns() == 2
        result = [2, 3, 6, 7, 10, 11]
        actual = list(r.enumerate())
        eq_(result, actual)
        # filter out all
        r = pe.load((self.file_type, self.testfile.getvalue()))
        r.filter(pe.sheets.filters.ColumnFilter([0, 1, 2, 3]))
        assert r.number_of_columns() == 0
        result = []
        actual = list(r.enumerate())
        eq_(result, actual)
github pyexcel / pyexcel / tests / test_filter.py View on Github external
def test_even_column_filter(self):
        r = pe.load((self.file_type, self.testfile.getvalue()))
        r.filter(pe.sheets.filters.EvenColumnFilter())
        assert r.number_of_rows() == 3
        assert r.number_of_columns() == 2
        result = [1, 3, 5, 7, 9, 11]
        actual = list(r.enumerate())
        eq_(result, actual)
github pyexcel / pyexcel / tests / test_filter.py View on Github external
def test_row_value_filter(self):
        r1 = pe.load("testcsv1.csv")
        r2 = pe.load("testcsv2.csv")

        def filter_func(array):
            def func(row): return array[0] == row[0] and array[1] == row[1]
            return r2.contains(func)
        r1.filter(pe.sheets.filters.RowValueFilter(filter_func).invert())
        result = [1, 'a', 2, 'b', 3, 'c', 8, 'h']
        actual = list(r1.enumerate())
        self.assertEqual(result, actual)
github pyexcel / pyexcel / tests / test_io_csvzipbook.py View on Github external
def test_read_custom_made_csvz(self):
        data = [[1, 4, 9], [2, 5, 8], [3, 6, 7]]
        sheet = pe.load(os.path.join("tests", "fixtures", "test-single.csvz"))
        sheet.format(int)
        result = sheet.to_array()
        assert data == result
github pyexcel / pyexcel / tests / test_multiple_sheets.py View on Github external
def test_non_default_sheet_as_single_sheet_plain_reader(self):
        r = pe.load(self.testfile, "Sheet2")
        data = list(r.rows())
        assert data == self.content["Sheet2"]
github pyexcel / pyexcel / tests / test_filter.py View on Github external
def test_row_filter(self):
        r = pe.load((self.file_type, self.testfile.getvalue()))
        r.filter(pe.sheets.filters.RowFilter([1]))
        assert r.number_of_rows() == 2
        assert r.number_of_columns() == 4
        result = [1, 2, 3, 4, 9, 10, 11, 12]
        actual = list(r.enumerate())
        eq_(result, actual)
        # filter out last column and first column
        r = pe.load((self.file_type, self.testfile.getvalue()))
        r.filter(pe.sheets.filters.RowFilter([0, 2]))
        assert r.number_of_rows() == 1
        assert r.number_of_columns() == 4
        result = [5, 6, 7, 8]
        actual = list(r.enumerate())
        eq_(result, actual)
        # filter out all
        r = pe.load((self.file_type, self.testfile.getvalue()))
        r.filter(pe.sheets.filters.RowFilter([0, 1, 2]))
        assert r.number_of_rows() == 0
        result = []
        actual = list(r.enumerate())
        eq_(result, actual)
github pyexcel / pyexcel-xls / tests / test_bug_fixes.py View on Github external
def test_pyexcel_issue_5():
    """pyexcel issue #5

    datetime is not properly parsed
    """
    s = pe.load(get_fixture("test-date-format.xls"))
    assert s[0, 0] == datetime.datetime(2015, 11, 11, 11, 12, 0)
github pyexcel / pyexcel / examples / cookbook / merge_sheets.py View on Github external
def main(base_dir):
    merged = pe.Book()
    files = glob.glob(os.path.join(base_dir, "scattered-csv-files", "*.csv"))
    for csv_file in files:
        merged += pe.load(csv_file)
    merged.save_as("merged.xls")