ExcelImporter

class qf_lib.documents_utils.excel.excel_importer.ExcelImporter[source]

Bases: object

Class used for importing Series and DataFrames from the Excel files.

Methods

import_cell(file_path, cell_address, sheet_name)

Imports a container of given type (e.g.

import_container(file_path, starting_cell, …)

Imports a container of given type (e.g.

import_cell(file_path: str, cell_address: str, sheet_name: str = None) → Union[int, float, str][source]

Imports a container of given type (e.g. Series/DataFrame) from the Excel file of a given name.

Parameters
  • file_path – path to the file containing the data to be imported

  • cell_address – address of the cell that you want to get (e.g. ‘A1’)

  • sheet_name – the name of the sheet from which the container should be imported. If no name is given, the active worksheet is used.

Returns

object containing the imported value

Return type

container

import_container(file_path: str, starting_cell: str, ending_cell: str, container_type: type = None, sheet_name: str = None, include_index: bool = True, include_column_names: bool = False) → Union[qf_lib.containers.series.qf_series.QFSeries, qf_lib.containers.dataframe.qf_dataframe.QFDataFrame][source]

Imports a container of given type (e.g. Series/DataFrame) from the Excel file of a given name.

Parameters
  • file_path – path to the file containing the data to be imported

  • starting_cell – top left corner of the imported container (e.g. A1)

  • ending_cell – bottom right corner of the imported container (e.g. B10)

  • container_type – type of the container to import. If none is given, then it is inferred from the bounding box (Series, if there is a single column, DataFrame for multiple columns). Other custom series and dataframe types that extend the Series and DataFrame types can also be used, this includes QFSeries and QFDataFrame.

  • sheet_name – the name of the sheet from which the container should be imported. If no name is given, the active worksheet is used.

  • include_index – if True than it is assumed that index is placed in the first column while values are starting from the 2nd column

  • include_column_names – determines whether the first row in the specified container contains the column names.

Returns

object containing the imported data

Return type

container