当前位置: 首页>>代码示例>>Python>>正文


Python pyexcel.get_book方法代码示例

本文整理汇总了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"] 
开发者ID:pyexcel,项目名称:pyexcel-xlsxw,代码行数:19,代码来源:test_multiple_sheets.py

示例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"] 
开发者ID:pyexcel,项目名称:pyexcel-odsr,代码行数:19,代码来源:test_multiple_sheets.py

示例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) 
开发者ID:pyexcel,项目名称:pyexcel-cli,代码行数:20,代码来源:test_split.py

示例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() 
开发者ID:pyexcel,项目名称:pyexcel-cli,代码行数:22,代码来源:test_split.py

示例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) 
开发者ID:pyexcel,项目名称:pyexcel-cli,代码行数:27,代码来源:test_merge.py

示例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'] 
开发者ID:pyexcel,项目名称:pyexcel-xlsxw,代码行数:7,代码来源:test_multiple_sheets.py

示例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'] 
开发者ID:pyexcel,项目名称:pyexcel-xlsxw,代码行数:7,代码来源:test_multiple_sheets.py

示例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) 
开发者ID:pyexcel,项目名称:pyexcel-xlsxw,代码行数:4,代码来源:test_multiple_sheets.py

示例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") 
开发者ID:pyexcel,项目名称:pyexcel-xlsxw,代码行数:4,代码来源:test_multiple_sheets.py

示例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 
开发者ID:adfinis-sygroup,项目名称:timed-backend,代码行数:17,代码来源:test_report.py

示例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 
开发者ID:pyexcel,项目名称:pyexcel-odsr,代码行数:6,代码来源:test_bug_fixes.py

示例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) 
开发者ID:pyexcel,项目名称:pyexcel-odsr,代码行数:10,代码来源:test_formatters.py

示例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) 
开发者ID:pyexcel,项目名称:pyexcel-odsr,代码行数:10,代码来源:test_formatters.py

示例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'] 
开发者ID:pyexcel,项目名称:pyexcel-odsr,代码行数:7,代码来源:test_multiple_sheets.py

示例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') 
开发者ID:pyexcel,项目名称:pyexcel-odsr,代码行数:5,代码来源:test_multiple_sheets.py


注:本文中的pyexcel.get_book方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。