本文整理汇总了Python中pyexcel.load_book函数的典型用法代码示例。如果您正苦于以下问题:Python load_book函数的具体用法?Python load_book怎么用?Python load_book使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了load_book函数的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_delete_sheets
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
示例2: test_delete_sheets2
def test_delete_sheets2(self):
"""Can delete by index"""
b1 = pe.load_book(self.testfile)
assert len(b1.sheet_names()) == 3
del b1[2]
del b1[1]
assert len(b1.sheet_names()) == 1
del b1[1] # bang, already deleted
示例3: test_delete_sheets2
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
示例4: test_read_multiple_csv_into_book
def test_read_multiple_csv_into_book(self):
book = pe.load_book(self.testfile)
assert book.sheet_names() == ["Sheet1", "Sheet2", "Sheet3"]
book["Sheet1"].format(int)
assert self.content["Sheet1"] == book["Sheet1"].to_array()
book["Sheet2"].format(int)
assert self.content["Sheet2"] == book["Sheet2"].to_array()
book["Sheet3"].format(int)
assert self.content["Sheet3"] == book["Sheet3"].to_array()
示例5: test_read_custom_made_csvz_multiple_hseet
def test_read_custom_made_csvz_multiple_hseet(self):
data = [[1, 4, 9], [2, 5, 8], [3, 6, 7]]
book = pe.load_book(os.path.join("tests", "fixtures", "test-multiple.csvz"))
assert book.sheet_names() == ["sheet1", "sheet2", "sheet3"]
book[0].format(int)
book[1].format(int)
book[2].format(int)
assert data == book[0].to_array()
assert data == book[1].to_array()
assert data == book[2].to_array()
示例6: test_issue_03
def test_issue_03(self):
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 = pe.Sheet(data, name=my_sheet_name)
sheet.save_as(csv_file)
assert(os.path.exists(csv_file))
sheet.save_as(xls_file)
book = pe.load_book(xls_file)
assert book.sheet_names()[0] == my_sheet_name
os.unlink(csv_file)
os.unlink(xls_file)
示例7: test_delete_sheets
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
示例8: test_load_a_single_sheet4
def test_load_a_single_sheet4(self):
pyexcel.load_book(self.testfile, sheet_name="Not exist")
示例9: test_load_a_single_sheet3
def test_load_a_single_sheet3(self):
pyexcel.load_book(self.testfile, sheet_index=10000)
示例10: test_load_a_single_sheet2
def test_load_a_single_sheet2(self):
b1 = pyexcel.load_book(self.testfile, sheet_index=2)
assert len(b1.sheet_names()) == 1
assert b1['Sheet3'].to_array() == self.content['Sheet3']
示例11: test_book_reader_to_dict2
def test_book_reader_to_dict2(self):
r = pe.load_book(self.testfile)
actual = r.to_dict()
self.assertEqual(self.content, actual)
示例12: test_delete_sheets3
def test_delete_sheets3(self):
"""Test float in []"""
b1 = pe.load_book(self.testfile)
del b1[1.1]
示例13: test_load_a_single_sheet2
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']
示例14: test_book_reader_to_dict2
def test_book_reader_to_dict2(self):
r = pe.load_book(self.testfile)
actual = r.to_dict()
assert actual == self.content