bw2io.importers
#
Submodules#
bw2io.importers.base
bw2io.importers.base_lci
bw2io.importers.base_lcia
bw2io.importers.ecoinvent_lcia
bw2io.importers.ecospold1
bw2io.importers.ecospold1_lcia
bw2io.importers.ecospold2
bw2io.importers.ecospold2_biosphere
bw2io.importers.excel
bw2io.importers.excel_lcia
bw2io.importers.exiobase2
bw2io.importers.exiobase3_hiot
bw2io.importers.simapro_csv
bw2io.importers.simapro_lcia_csv
Package Contents#
Classes#
Generic CSV importer |
|
Generic CSV LCIA importer |
|
Generic Excel importer. |
|
Generic Excel LCIA importer. |
|
Import and process mutli-output datasets in the ecospold 1 format. |
|
Import and process single-output datasets in the ecospold 1 format. |
|
Import and process single-output datasets in the ecospold 1 format. |
|
Base class for format-specific importers. |
- class bw2io.importers.CSVImporter(filepath)[source]#
Bases:
ExcelImporter
Generic CSV importer
- extractor#
- format = 'CSV'#
- class bw2io.importers.CSVLCIAImporter(filepath, name, description, unit, **metadata)[source]#
Bases:
ExcelLCIAImporter
Generic CSV LCIA importer
- extractor#
- format = 'CSV'#
- class bw2io.importers.EcoinventLCIAImporter[source]#
Bases:
bw2io.importers.base_lcia.LCIAImporter
- 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
- format = 'Ecospold1 LCIA'#
- class bw2io.importers.Ecospold2BiosphereImporter(name='biosphere3', version='3.9')[source]#
Bases:
bw2io.importers.base_lci.LCIImporter
- format = 'Ecoinvent XML'#
- extract(version)#
- class bw2io.importers.ExcelImporter(filepath)[source]#
Bases:
bw2io.importers.base_lci.LCIImporter
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
andFalse
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 likecsv_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, butactivate_parameters
is True by default.
- write_database_parameters(activate_parameters=True, delete_existing=True)#
Same as base
write_database_parameters
method, butactivate_parameters
is True by default.
- class bw2io.importers.ExcelLCIAImporter(filepath, name, description, unit, **metadata)[source]#
Bases:
bw2io.importers.base_lcia.LCIAImporter
Generic Excel LCIA importer.
See the documentation.
- extractor#
- format = 'Excel'#
- class bw2io.importers.MultiOutputEcospold1Importer(*args, **kwargs)[source]#
Bases:
SingleOutputEcospold1Importer
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
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 acode
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
- 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
- format = 'SimaPro CSV LCIA'#
- class bw2io.importers.SingleOutputEcospold1Importer(filepath, db_name, use_mp=True, extractor=Ecospold1DataExtractor)[source]#
Bases:
bw2io.importers.base_lci.LCIImporter
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 acode
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
Base class for format-specific importers.
Defines workflow for applying strategies.
Takes a database name (string) as initialization parameter.
- format = 'Ecospold2'#