bw2io.extractors.excel#

Module Contents#

Classes#

ExcelExtractor

Extract data from an Excel file.

Functions#

get_cell_value_handle_error(cell)

Get the value of a cell, handling error types.

class bw2io.extractors.excel.ExcelExtractor[source]#

Bases: object

Extract data from an Excel file.

Parameters

object (type) – The parent object for the ExcelExtractor class

Returns

An instance of the class

Return type

object

classmethod extract(filepath)[source]#

Extract data from an Excel file.

Parameters

filepath (str) – The path to the Excel file.

Returns

A list of tuples containing the name of each sheet in the file and the data from each sheet.

Return type

list

Raises

AssertionError – If the file at β€˜filepath’ does not exist.

classmethod extract_sheet(wb, name, strip=True)[source]#

Extract data from a single sheet in an Excel file.

Parameters
  • wb (openpyxl.workbook.Workbook) – The workbook object with the sheet to extract data from.

  • name (str) – The name of the sheet to extract data from.

  • strip (bool, optional) – If True, strip whitespace from cell values, by default True.

Returns

A list of lists containing the data from each cell in the sheet.

Return type

list

bw2io.extractors.excel.get_cell_value_handle_error(cell)[source]#

Get the value of a cell, handling error types.

Parameters

cell (openpyxl.cell.cell.cell) – The cell to retrieve the value from.

Returns

The value of the cell, or None if the cell has an error type.

Return type

object