How to use the pyexcel.load_book 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_multiple_sheets.py View on Github external
def test_delete_sheets(self):
        """Can delete by sheet name"""
        b1 = pe.load_book(self.testfile)
        assert len(b1.sheet_names()) == 3
        del b1["Sheet1"]
        assert len(b1.sheet_names()) == 2
        del b1["Sheet1"]  # bang, already deleted
github pyexcel / pyexcel-ods3 / tests / test_multiple_sheets.py View on Github external
def test_delete_sheets(self):
        b1 = pyexcel.load_book(self.testfile)
        assert len(b1.sheet_names()) == 3
        del b1["Sheet1"]
        assert len(b1.sheet_names()) == 2
        try:
            del b1["Sheet1"]
            assert 1 == 2
        except KeyError:
            assert 1 == 1
        del b1[1]
        assert len(b1.sheet_names()) == 1
        try:
            del b1[1]
            assert 1 == 2
        except IndexError:
            assert 1 == 1
github pyexcel / pyexcel / tests / test_bug_fixes.py View on Github external
def test_issue_03():
    file_prefix = "issue_03_test"
    csv_file = "%s.csv" % file_prefix
    xls_file = "%s.xls" % file_prefix
    my_sheet_name = "mysheetname"
    data = [[1, 1]]
    sheet = p.Sheet(data, name=my_sheet_name)
    sheet.save_as(csv_file)
    assert os.path.exists(csv_file)
    sheet.save_as(xls_file)
    book = p.load_book(xls_file)
    assert book.sheet_names()[0] == my_sheet_name
    os.unlink(csv_file)
    os.unlink(xls_file)
github pyexcel / pyexcel / tests / test_multiple_sheets.py View on Github external
def test_load_a_single_sheet2(self):
        b1 = pe.load_book(self.testfile, sheet_index=1)
        b1["Sheet2"].format(int)
        assert len(b1.sheet_names()) == 1
        assert b1["Sheet2"].to_array() == self.content["Sheet2"]
github pyexcel / pyexcel-xlsx / tests / test_multiple_sheets.py View on Github external
def test_delete_sheets(self):
        b1 = pyexcel.load_book(self.testfile)
        assert len(b1.sheet_names()) == 3
        del b1["Sheet1"]
        assert len(b1.sheet_names()) == 2
        try:
            del b1["Sheet1"]
            assert 1 == 2
        except KeyError:
            assert 1 == 1
        del b1[1]
        assert len(b1.sheet_names()) == 1
        try:
            del b1[1]
            assert 1 == 2
        except IndexError:
            assert 1 == 1
github pyexcel / pyexcel-xlsx / tests / test_multiple_sheets.py View on Github external
def test_delete_sheets2(self):
        """repetitively delete first sheet"""
        b1 = pyexcel.load_book(self.testfile)
        del b1[0]
        assert len(b1.sheet_names()) == 2
        del b1[0]
        assert len(b1.sheet_names()) == 1
        del b1[0]
        assert len(b1.sheet_names()) == 0
github pyexcel / pyexcel / tests / test_multiple_sheets.py View on Github external
def test_load_a_single_sheet4(self):
        pe.load_book(self.testfile, sheet_name="Not exist")
github pyexcel / pyexcel / tests / test_multiple_sheets.py View on Github external
def test_delete_sheets4(self):
        """repetitively delete first sheet"""
        b1 = pe.load_book(self.testfile)
        del b1[0]
        assert len(b1.sheet_names()) == 2
        del b1[0]
        assert len(b1.sheet_names()) == 1
        del b1[0]
        assert len(b1.sheet_names()) == 0