Excel Extractor

class etk.extractors.excel_extractor.ExcelExtractor(etk: etk.etk.ETK = None, extractor_name: str = 'excel extractor')[source]

Bases: etk.extractor.Extractor

Description
This class is a wrapper of pyexcel. By defining ‘variables’ argument, this extractor is able to extract multiple information and store them into different field at once.

Examples

excel_extractor = ExcelExtractor()
excel_extractor.extract(file_name:path_to_excel,
                        sheet_name:sheet_name,
                        region:['A,1', 'Z,10'],
                        variables={
                            # get current col & row for field1
                            'field1': '$col,$row',
                            # get fixed cell of $A,$5 for field2
                            'field2': '$A,$5'
                            })
extract(file_name: str, sheet_name: str, region: List, variables: Dict) → List[etk.extraction.Extraction][source]
Parameters:
  • file_name (str) – file name
  • sheet_name (str) – sheet name
  • region (List[]) – from upper left cell to bottom right cell, e.g., [‘A,1’, ‘Z,10’]
  • variables (Dict) – key is variable name, value can be: 1. a single expression 2. comma separated expression, will be treated as location $row, $col are built-in variables can be used in expression constant row and column value can be noted as $NAME (e.g., $1, $10, $A, $GG)
Returns:

A list of extracted variables dictionary

Return type:

List[Extraction]