本文整理匯總了Python中pyexcel.get_book方法的典型用法代碼示例。如果您正苦於以下問題:Python pyexcel.get_book方法的具體用法?Python pyexcel.get_book怎麽用?Python pyexcel.get_book使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類pyexcel
的用法示例。
在下文中一共展示了pyexcel.get_book方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_add_book1
# 需要導入模塊: import pyexcel [as 別名]
# 或者: from pyexcel import get_book [as 別名]
def test_add_book1(self):
"""
test this scenario: book3 = book1 + book2
"""
b1 = pyexcel.get_book(file_name=self.testfile)
b2 = pyexcel.get_book(file_name=self.testfile2)
b3 = b1 + b2
content = b3.dict
sheet_names = content.keys()
assert len(sheet_names) == 6
for name in sheet_names:
if "Sheet3" in name:
assert content[name] == self.content["Sheet3"]
elif "Sheet2" in name:
assert content[name] == self.content["Sheet2"]
elif "Sheet1" in name:
assert content[name] == self.content["Sheet1"]
示例2: test_add_book1
# 需要導入模塊: import pyexcel [as 別名]
# 或者: from pyexcel import get_book [as 別名]
def test_add_book1(self):
"""
test this scenario: book3 = book1 + book2
"""
b1 = pyexcel.get_book(file_name=self.testfile, library='pyexcel-odsr')
b2 = pyexcel.get_book(file_name=self.testfile2)
b3 = b1 + b2
content = b3.dict
sheet_names = content.keys()
assert len(sheet_names) == 6
for name in sheet_names:
if "Sheet3" in name:
assert content[name] == self.content["Sheet3"]
elif "Sheet2" in name:
assert content[name] == self.content["Sheet2"]
elif "Sheet1" in name:
assert content[name] == self.content["Sheet1"]
示例3: test_output_option
# 需要導入模塊: import pyexcel [as 別名]
# 或者: from pyexcel import get_book [as 別名]
def test_output_option():
runner = CliRunner()
file_fixture = os.path.join("tests", "fixtures", "multiple-sheets.xls")
prefix = "output"
result = runner.invoke(split, ['--output-file-type', 'xlsx',
'--output-dir', 'tests',
file_fixture, prefix])
eq_(result.exit_code, 0)
book = get_book(file_name=file_fixture)
count = 0
for sheet in book:
splitted_file = os.path.join(
"tests",
"%s_%s_%s.xlsx" % (prefix, sheet.name, count))
count += 1
written_sheet = get_sheet(file_name=splitted_file)
eq_(str(sheet), str(written_sheet))
os.unlink(splitted_file)
示例4: test_stdin_option
# 需要導入模塊: import pyexcel [as 別名]
# 或者: from pyexcel import get_book [as 別名]
def test_stdin_option():
runner = CliRunner()
file_fixture = os.path.join("tests", "fixtures", "multiple-sheets.xls")
input_stream = open(file_fixture, "rb")
prefix = "output"
result = runner.invoke(split,
['--source-file-type', "xls",
'--output-file-type', 'xlsx',
'-', prefix],
input=input_stream.read())
eq_(result.exit_code, 0)
book = get_book(file_name=file_fixture)
count = 0
for sheet in book:
splitted_file = "%s_%s_%s.xlsx" % (prefix, sheet.name, count)
count += 1
written_sheet = get_sheet(file_name=splitted_file)
eq_(str(sheet), str(written_sheet))
os.unlink(splitted_file)
input_stream.close()
示例5: test_simple_option
# 需要導入模塊: import pyexcel [as 別名]
# 或者: from pyexcel import get_book [as 別名]
def test_simple_option():
runner = CliRunner()
file_fixture = os.path.join("tests", "fixtures", "transcode_simple.csv")
dir_fixture = os.path.join("tests", "fixtures", "file_dir")
glob_fixture = os.path.join("tests", "fixtures", "glob_dir", "*")
output = "test_simple_option.xls"
result = runner.invoke(merge, [file_fixture, dir_fixture, glob_fixture,
output])
eq_(result.exit_code, 0)
book = get_book(file_name=output)
expected = dedent("""
transcode_simple.csv:
+---+---+---+
| 1 | 2 | 3 |
+---+---+---+
merge_test.csv:
+---+---+---+
| 1 | 2 | 3 |
+---+---+---+
merge_test2.csv:
+---+---+---+
| 1 | 2 | 3 |
+---+---+---+""").strip('\n')
eq_(str(book), expected)
os.unlink(output)
示例6: test_load_a_single_sheet
# 需要導入模塊: import pyexcel [as 別名]
# 或者: from pyexcel import get_book [as 別名]
def test_load_a_single_sheet(self):
b1 = pyexcel.get_book(file_name=self.testfile, sheet_name="Sheet1",
library="pyexcel-xls")
assert len(b1.sheet_names()) == 1
assert b1['Sheet1'].to_array() == self.content['Sheet1']
示例7: test_load_a_single_sheet2
# 需要導入模塊: import pyexcel [as 別名]
# 或者: from pyexcel import get_book [as 別名]
def test_load_a_single_sheet2(self):
b1 = pyexcel.get_book(file_name=self.testfile, sheet_index=1,
library="pyexcel-xls")
assert len(b1.sheet_names()) == 1
assert b1['Sheet2'].to_array() == self.content['Sheet2']
示例8: test_load_a_single_sheet3
# 需要導入模塊: import pyexcel [as 別名]
# 或者: from pyexcel import get_book [as 別名]
def test_load_a_single_sheet3(self):
pyexcel.get_book(file_name=self.testfile, sheet_index=10000)
示例9: test_load_a_single_sheet4
# 需要導入模塊: import pyexcel [as 別名]
# 或者: from pyexcel import get_book [as 別名]
def test_load_a_single_sheet4(self):
pyexcel.get_book(file_name=self.testfile, sheet_name="Not exist")
示例10: test_report_export
# 需要導入模塊: import pyexcel [as 別名]
# 或者: from pyexcel import get_book [as 別名]
def test_report_export(auth_client, file_type, django_assert_num_queries):
reports = ReportFactory.create_batch(2)
url = reverse('report-export')
with django_assert_num_queries(2):
response = auth_client.get(url, data={'file_type': file_type})
assert response.status_code == status.HTTP_200_OK
book = pyexcel.get_book(
file_content=response.content, file_type=file_type
)
# bookdict is a dict of tuples(name, content)
sheet = book.bookdict.popitem()[1]
assert len(sheet) == len(reports) + 1
示例11: test_issue_23
# 需要導入模塊: import pyexcel [as 別名]
# 或者: from pyexcel import get_book [as 別名]
def test_issue_23():
if not IN_TRAVIS:
raise SkipTest()
pe.get_book(url="https://github.com/pyexcel/pyexcel-ods/raw/master/tests/fixtures/white_space.ods", library='pyexcel-odsr'); # flake8: noqa
示例12: test_get_book_auto_detect_int
# 需要導入模塊: import pyexcel [as 別名]
# 或者: from pyexcel import get_book [as 別名]
def test_get_book_auto_detect_int(self):
book = pe.get_book(file_name=self.test_file)
expected = dedent("""
pyexcel_sheet1:
+---+---+-----+
| 1 | 2 | 3.1 |
+---+---+-----+""").strip()
self.assertEqual(str(book), expected)
示例13: test_get_book_auto_detect_int_false
# 需要導入模塊: import pyexcel [as 別名]
# 或者: from pyexcel import get_book [as 別名]
def test_get_book_auto_detect_int_false(self):
book = pe.get_book(file_name=self.test_file, auto_detect_int=False)
expected = dedent("""
pyexcel_sheet1:
+-----+-----+-----+
| 1.0 | 2.0 | 3.1 |
+-----+-----+-----+""").strip()
self.assertEqual(str(book), expected)
示例14: test_load_a_single_sheet
# 需要導入模塊: import pyexcel [as 別名]
# 或者: from pyexcel import get_book [as 別名]
def test_load_a_single_sheet(self):
b1 = pyexcel.get_book(file_name=self.testfile, sheet_name="Sheet1",
library='pyexcel-odsr')
assert len(b1.sheet_names()) == 1
assert b1['Sheet1'].to_array() == self.content['Sheet1']
示例15: test_load_a_single_sheet3
# 需要導入模塊: import pyexcel [as 別名]
# 或者: from pyexcel import get_book [as 別名]
def test_load_a_single_sheet3(self):
pyexcel.get_book(file_name=self.testfile, sheet_index=10000,
library='pyexcel-odsr')