How to use the pyexcel.get_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-ods / tests / test_multiple_sheets.py View on Github external
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"]
github pyexcel / pyexcel-ods / tests / test_formatters.py View on Github external
def test_get_book_auto_detect_int(self):
        book = pe.get_book(file_name=self.test_file, library="pyexcel-ods")
        expected = dedent(
            """
        pyexcel_sheet1:
        +---+---+-----+
        | 1 | 2 | 3.1 |
        +---+---+-----+"""
        ).strip()
        eq_(str(book), expected)
github pyexcel / pyexcel-ods / tests / test_multiple_sheets.py View on Github external
def test_load_a_single_sheet(self):
        b1 = pyexcel.get_book(file_name=self.testfile, sheet_name="Sheet1")
        assert len(b1.sheet_names()) == 1
        assert b1["Sheet1"].to_array() == self.content["Sheet1"]
github pyexcel / pyexcel-ods / tests / test_formatters.py View on Github external
def test_get_book_auto_detect_int_false(self):
        book = pe.get_book(
            file_name=self.test_file,
            auto_detect_int=False,
            library="pyexcel-ods",
        )
        expected = dedent(
            """
        pyexcel_sheet1:
        +-----+-----+-----+
        | 1.0 | 2.0 | 3.1 |
        +-----+-----+-----+"""
        ).strip()
        eq_(str(book), expected)
github pyexcel / pyexcel-io / tests / test_pyexcel_integration.py View on Github external
def test_get_book_auto_detect_int(self):
        book = pe.get_book(file_name=self.test_file)
        expected = dedent(
            """
        test_auto_detect_init.csv:
        +---+---+-----+
        | 1 | 2 | 3.1 |
        +---+---+-----+"""
        ).strip()
        self.assertEqual(str(book), expected)
github usc-isi-i2 / t2wml / Code / handler.py View on Github external
def add_excel_file_to_bindings(excel_filepath: str, sheet_name: str) -> None:
    """
    This function reads the excel file and add the pyexcel object to the bindings
    :return: None
    """
    try:
        records = pyexcel.get_book(file_name=excel_filepath)
        if not sheet_name:
            bindings["excel_sheet"] = records[0]
        else:
            bindings["excel_sheet"] = records[sheet_name]

    except IOError:
        raise IOError('Excel File cannot be found or opened')
github CompEpigen / CWLab / cwlab / wf_input / read_xls.py View on Github external
def sheet_file( sheet_file, verbose_level=2):
    sheets = pe.get_book(file_name=sheet_file)
    print_pref = "[sheet_file]:"
    param_values = {}
    configs = {}
    metadata = {}

    for sheet_idx, sheet in enumerate(sheets):
        try:
            param_values_tmp, configs_tmp, metadata_ = spread_sheet(sheet, verbose_level)
            metadata.update(metadata_)
        except AssertionError as e:
           raise AssertionError( print_pref + "failed to read sheet \"" + str(sheet.name) + "\":" + str(e))
        
        # merge with existing data, conflicting data not allowed:
        if len(set(param_values_tmp.keys()).intersection(param_values.keys())) > 0:
            raise AssertionError(print_pref + "E: conflicting parameter values, did you specify parameters muliple time?")
        elif len(set(configs_tmp.keys()).intersection(configs.keys())) > 0:
github pyexcel-renderers / sphinxcontrib-excel / sphinxcontrib / excel.py View on Github external
if len(self.arguments) > 0:
            fn = search_image_for_language(self.arguments[0], env)
            relfn, excel_file = env.relfn2path(fn)
            env.note_dependency(relfn)
            if self.options:
                width = self.options.get('width', 600)
                height = self.options.get('height')
            book = pyexcel.get_book(file_name=excel_file)
        else:
            content = '\n'.join(self.content)
            if '---pyexcel' in content:
                multiple_sheets = True
            else:
                multiple_sheets = False
            book = pyexcel.get_book(file_content='\n'.join(self.content),
                                    multiple_sheets=multiple_sheets,
                                    lineterminator='\n',
                                    file_type='csv')
        html = self.render_html(book, width, height)
        return [docutils.nodes.raw('', html,
                                   format='html')]
github quinlan-lab / pathoscore / truth-sets / GRCh37 / homsy / make.py View on Github external
from __future__ import print_function
import sys

import pyexcel as pe

path_book = pe.get_book(file_name=sys.argv[1])
benign_book = pe.get_book(file_name=sys.argv[2])

bfh = open('homsy.benign.vcf', 'w')
pfh = open('homsy.pathogenic.vcf', 'w')
header = """##fileformat=VCFv4.1
##source=pathoscore
##reference=GRCh37
#CHROM	POS	ID	REF	ALT	QUAL	FILTER	INFO"""

print(header, file=bfh)
print(header, file=pfh)

sheet = path_book['Database S2']
for i, record in enumerate(sheet):
    if i == 0:
        continue