REGISTER NOW: DdS Autumn School! 🇨🇭 Grosshöchstetten (Switzerland) 🗓️ 6.-11. October 2024

bw2io.extractors.simapro_lcia_csv#

Module Contents#

Classes#

SimaProLCIACSVExtractor

Extract data from SimaPro LCIACSV file format.

Attributes#

INTRODUCTION

SKIPPABLE_SECTIONS

strip_delete

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

Bases: Exception

Inheritance diagram of bw2io.extractors.simapro_lcia_csv.EndOfDatasets

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

List of datasets extracted from the SimaPro LCIACSV file.

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_datalist

A list of tuples containing normalization-weighting (NW) set names and scales.

category_datalist

A list of tuples containing impact category names, units, and CF data.

Returns#
list

A list of all CFs.

classmethod get_category_data(data, index)[source]#

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

Parameters#
datalist of lists

A list of lists with the data for all categories

indexint

The index of the current impact category in the list

Returns#
tuple

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

classmethod get_damage_category_data(data, index)[source]#

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

Parameters#
datalist of lists

A list of lists with the data of the damage categories

indexint

The index of the current damage category in the list

Returns#
tuple

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

classmethod get_damage_exchanges(damage_data, category_data)[source]#

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

Parameters#
damage_datalist of tuples

A list of tuples containing the name and scale of the damage

category_datalist of tuples

A list of tuples containing the name, unit, and data of each impact category

Returns#
list of dictionaries

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

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#
datalist of lists

The nested list containing the data.

indexint

The starting index to search for the next “Method”.

Returns#
int

The index of the next “Method” in the data.

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#
datalist

A list of lists containing the data to be processed.

indexint

The starting index to read metadata from.

Returns#
tuple

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

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

Read method data set from data starting at index.

Parameters#
datalist

A list of lists containing the data to be processed.

indexint

The starting index to read method data set from.

filepathstr

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#
datalist of lists

The nested list containing the data.

indexint

The starting index to skip from.

Returns#
int

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

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]#