bw2io.extractors.simapro_lcia_csv#

Attributes#

Exceptions#

EndOfDatasets

Common base class for all non-exit exceptions.

Classes#

SimaProLCIACSVExtractor

Extract data from SimaPro LCIACSV file format.

Module Contents#

exception bw2io.extractors.simapro_lcia_csv.EndOfDatasets[source]#

Bases: Exception

Common base class for all non-exit exceptions.

Initialize self. See help(type(self)) for accurate signature.

class bw2io.extractors.simapro_lcia_csv.SimaProLCIACSVExtractor[source]#

Bases: object

Extract data from SimaPro LCIACSV file format.

Parameters:
  • filepath (str) – Filepath of the SimaPro LCIACSV file.

  • delimiter (str, optional (default: ";")) – Delimiter used in the SimaPro LCIACSV file.

  • encoding (str, optional (default: "cp1252")) – Encoding of the SimaPro LCIACSV file.

Raises:

AssertionError – If the filepath does not exist or the file is not a valid SimaPro export file.

Returns:

List of datasets extracted from the SimaPro LCIACSV file.

Return type:

list

classmethod extract(filepath, delimiter=';', encoding='cp1252', **kwargs)[source]#
classmethod get_all_cfs(nw_data, category_data)[source]#

Get all CFs from nw_data and category_data.

Parameters:
  • nw_data (list) – A list of tuples containing normalization-weighting (NW) set names and scales.

  • category_data (list) – A list of tuples containing impact category names, units, and CF data.

Returns:

A list of all CFs.

Return type:

list

classmethod get_category_data(data, index)[source]#

Parse impact category data and return its name, unit, and data.

Parameters:
  • data (list of lists) – A list of lists with the data for all categories

  • index (int) – The index of the current impact category in the list

Returns:

A tuple with the name, unit, and data for the impact category

Return type:

tuple

classmethod get_damage_category_data(data, index)[source]#

Parse damage category data and return the name, unit, and data of the category.

Parameters:
  • data (list of lists) – A list of lists with the data of the damage categories

  • index (int) – The index of the current damage category in the list

Returns:

A tuple with the name, unit, and data for the damage category

Return type:

tuple

classmethod get_damage_exchanges(damage_data, category_data)[source]#

Calculate the damage exchanges based on damage data and category data.

Parameters:
  • damage_data (list of tuples) – A list of tuples containing the name and scale of the damage

  • category_data (list of tuples) – A list of tuples containing the name, unit, and data of each impact category

Returns:

A list of dictionaries with the calculated damage exchanges of each impact category

Return type:

list of dictionaries

classmethod get_next_method_index(data, index)[source]#

Find the index of the next β€œMethod” in the given data starting from the specified index, skipping any sections specified in SKIPPABLE_SECTIONS.

Parameters:
  • data (list of lists) – The nested list containing the data.

  • index (int) – The starting index to search for the next β€œMethod”.

Returns:

The index of the next β€œMethod” in the data.

Return type:

int

Raises:

EndOfDatasets – If the file ends without extra metadata.

classmethod get_normalization_weighting_data(data, index)[source]#
classmethod parse_cf(line)[source]#

Parse line in Substances section.

  1. category

  2. subcategory

  3. flow

  4. CAS number

  5. CF

  6. unit

classmethod read_metadata(data, index)[source]#

Read metadata from data starting at index.

Parameters:
  • data (list) – A list of lists containing the data to be processed.

  • index (int) – The starting index to read metadata from.

Returns:

A tuple containing a dictionary of metadata and the index where the metadata reading ended.

Return type:

tuple

classmethod read_method_data_set(data, index, filepath)[source]#

Read method data set from data starting at index.

Parameters:
  • data (list) – A list of lists containing the data to be processed.

  • index (int) – The starting index to read method data set from.

  • filepath (str) – The file path of the method data set.

Returns:

  • list – A list of completed method data sets.

  • int – The index where the method data set reading ended.

Raises:

ValueError –

classmethod skip_to_section_end(data, index)[source]#

Skip to the end of the current section in the data starting from the specified index.

Parameters:
  • data (list of lists) – The nested list containing the data.

  • index (int) – The starting index to skip from.

Returns:

The index of the end of the current section in the data.

Return type:

int

bw2io.extractors.simapro_lcia_csv.INTRODUCTION = Multiline-String[source]#
Show Value
"""Starting SimaPro import:
  Filepath: %s
  Delimiter: %s
"""
bw2io.extractors.simapro_lcia_csv.SKIPPABLE_SECTIONS[source]#
bw2io.extractors.simapro_lcia_csv.strip_delete[source]#