bw2io.importers#

Submodules#

Package Contents#

Classes#

CSVImporter

Generic CSV importer

CSVLCIAImporter

Generic CSV LCIA importer

EcoinventLCIAImporter

Ecospold1LCIAImporter

Ecospold2BiosphereImporter

ExcelImporter

Generic Excel importer.

ExcelLCIAImporter

Generic Excel LCIA importer.

MultiOutputEcospold1Importer

Import and process mutli-output datasets in the ecospold 1 format.

NoIntegerCodesEcospold1Importer

Import and process single-output datasets in the ecospold 1 format.

SimaProCSVImporter

SimaProLCIACSVImporter

SingleOutputEcospold1Importer

Import and process single-output datasets in the ecospold 1 format.

SingleOutputEcospold2Importer

Base class for format-specific importers.

class bw2io.importers.CSVImporter(filepath)[source]#

Bases: ExcelImporter

Inheritance diagram of bw2io.importers.CSVImporter

Generic CSV importer

extractor#
format = 'CSV'#
class bw2io.importers.CSVLCIAImporter(filepath, name, description, unit, **metadata)[source]#

Bases: ExcelLCIAImporter

Inheritance diagram of bw2io.importers.CSVLCIAImporter

Generic CSV LCIA importer

extractor#
format = 'CSV'#
class bw2io.importers.EcoinventLCIAImporter[source]#

Bases: bw2io.importers.base_lcia.LCIAImporter

Inheritance diagram of bw2io.importers.EcoinventLCIAImporter
add_rationalize_method_names_strategy()#
separate_methods()#

Separate the list of CFs into distinct methods

class bw2io.importers.Ecospold1LCIAImporter(filepath, biosphere=None)[source]#

Bases: bw2io.importers.base_lcia.LCIAImporter

Inheritance diagram of bw2io.importers.Ecospold1LCIAImporter
format = 'Ecospold1 LCIA'#
class bw2io.importers.Ecospold2BiosphereImporter(name='biosphere3', version='3.9')[source]#

Bases: bw2io.importers.base_lci.LCIImporter

Inheritance diagram of bw2io.importers.Ecospold2BiosphereImporter
format = 'Ecoinvent XML'#
extract(version)#
class bw2io.importers.ExcelImporter(filepath)[source]#

Bases: bw2io.importers.base_lci.LCIImporter

Inheritance diagram of bw2io.importers.ExcelImporter

Generic Excel importer.

See the generic Excel example spreadsheet.

Excel spreadsheet should follow the following format:

::

Project parameters <variable>, <formula>, <amount>, metadata

Database, <name of database> <database field name>, <database field value>

Parameters <variable>, <formula>, <amount>, metadata

Activity, <name of activity> <database field name>, <database field value> Exchanges <field name>, <field name>, <field name> <value>, <value>, <value> <value>, <value>, <value>

Neither project parameters, parameters, nor exchanges for each activity are required.

An activity is marked as finished with a blank line.

In general, data is imported without modification. However, the following transformations are applied:

  • Numbers are translated from text into actual numbers.

  • Tuples, separated in the cell by the :: string, are reconstructed.

  • True and False are transformed to boolean values.

  • Fields with the value (Unknown) are dropped.

extractor#
format = 'Excel'#
get_activity(sn, ws)#
get_database(data)#
get_database_parameters(data)#
get_labelled_section(sn, ws, index=0, transform=True)#

Turn a list of rows into a list of dictionaries.

The first line of ws is the column labels. All subsequent rows are the data values. Missing columns are dropped.

transform is a boolean: perform CSV transformation functions like csv_restore_tuples.

get_metadata_section(sn, ws, index=0, transform=True)#
get_project_parameters(data)#

Extract project parameters (variables and formulas).

Project parameters are a section that starts with a line with the string “project parameters” (case-insensitive) in the first cell, and ends with a blank line. There can be multiple project parameter sections.

process_activities(data)#

Take list of (sheet names, raw data) and process it.

write_activity_parameters(data=None, delete_existing=True)#
write_database(**kwargs)#

Same as base write_database method, but activate_parameters is True by default.

write_database_parameters(activate_parameters=True, delete_existing=True)#

Same as base write_database_parameters method, but activate_parameters is True by default.

class bw2io.importers.ExcelLCIAImporter(filepath, name, description, unit, **metadata)[source]#

Bases: bw2io.importers.base_lcia.LCIAImporter

Inheritance diagram of bw2io.importers.ExcelLCIAImporter

Generic Excel LCIA importer.

See the documentation.

extractor#
format = 'Excel'#
class bw2io.importers.MultiOutputEcospold1Importer(*args, **kwargs)[source]#

Bases: SingleOutputEcospold1Importer

Inheritance diagram of bw2io.importers.MultiOutputEcospold1Importer

Import and process mutli-output datasets in the ecospold 1 format.

Works the same as the single-output importer, but first allocates multioutput datasets.

class bw2io.importers.NoIntegerCodesEcospold1Importer(*args, **kwargs)[source]#

Bases: SingleOutputEcospold1Importer

Inheritance diagram of bw2io.importers.NoIntegerCodesEcospold1Importer

Import and process single-output datasets in the ecospold 1 format.

Applies the following strategies: #. If only one exchange is a production exchange, that is the reference product #. Delete (unreliable) integer codes from extracted data #. Drop unspecified subcategories from biosphere flows #. Normalize biosphere flow categories to ecoinvent 3.1 standard #. Normalize biosphere flow names to ecoinvent 3.1 standard #. Remove locations from biosphere exchanges #. Create a code from the activity hash of the dataset #. Link biosphere exchanges to the default biosphere database #. Link internal technosphere exchanges

Parameters
  • filepath (*) – Either a file or directory.

  • db_name (*) – Name of database to create.

class bw2io.importers.SimaProCSVImporter(filepath, name=None, delimiter=';', encoding='latin-1', normalize_biosphere=True, biosphere_db=None)[source]#

Bases: bw2io.importers.base_lci.LCIImporter

Inheritance diagram of bw2io.importers.SimaProCSVImporter
format = 'SimaPro CSV'#
get_db_name()#
match_ecoinvent2(db_name)#
write_database(data=None, name=None, *args, **kwargs)#
class bw2io.importers.SimaProLCIACSVImporter(filepath, biosphere=None, delimiter=';', encoding='latin-1', normalize_biosphere=True)[source]#

Bases: bw2io.importers.base_lcia.LCIAImporter

Inheritance diagram of bw2io.importers.SimaProLCIACSVImporter
format = 'SimaPro CSV LCIA'#
class bw2io.importers.SingleOutputEcospold1Importer(filepath, db_name, use_mp=True, extractor=Ecospold1DataExtractor)[source]#

Bases: bw2io.importers.base_lci.LCIImporter

Inheritance diagram of bw2io.importers.SingleOutputEcospold1Importer

Import and process single-output datasets in the ecospold 1 format.

Applies the following strategies: #. If only one exchange is a production exchange, that is the reference product #. Delete (unreliable) integer codes from extracted data #. Drop unspecified subcategories from biosphere flows #. Normalize biosphere flow categories to ecoinvent 3.1 standard #. Normalize biosphere flow names to ecoinvent 3.1 standard #. Remove locations from biosphere exchanges #. Create a code from the activity hash of the dataset #. Link biosphere exchanges to the default biosphere database #. Link internal technosphere exchanges

Parameters
  • filepath (*) – Either a file or directory.

  • db_name (*) – Name of database to create.

format = 'Ecospold1'#
class bw2io.importers.SingleOutputEcospold2Importer(dirpath, db_name, extractor=Ecospold2DataExtractor, use_mp=True, signal=None)[source]#

Bases: bw2io.importers.base_lci.LCIImporter

Inheritance diagram of bw2io.importers.SingleOutputEcospold2Importer

Base class for format-specific importers.

Defines workflow for applying strategies.

Takes a database name (string) as initialization parameter.

format = 'Ecospold2'#