當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。