bw2io.importers =============== .. py:module:: bw2io.importers Submodules ---------- .. toctree:: :maxdepth: 1 /content/api/bw2io/importers/base/index /content/api/bw2io/importers/base_lci/index /content/api/bw2io/importers/base_lcia/index /content/api/bw2io/importers/ecoinvent_lcia/index /content/api/bw2io/importers/ecospold1/index /content/api/bw2io/importers/ecospold1_lcia/index /content/api/bw2io/importers/ecospold2/index /content/api/bw2io/importers/ecospold2_biosphere/index /content/api/bw2io/importers/excel/index /content/api/bw2io/importers/excel_lcia/index /content/api/bw2io/importers/exiobase2/index /content/api/bw2io/importers/exiobase3_hiot/index /content/api/bw2io/importers/simapro_csv/index /content/api/bw2io/importers/simapro_lcia_csv/index Classes ------- .. autoapisummary:: bw2io.importers.CSVImporter bw2io.importers.CSVLCIAImporter bw2io.importers.EcoinventLCIAImporter bw2io.importers.Ecospold1LCIAImporter bw2io.importers.Ecospold2BiosphereImporter bw2io.importers.ExcelImporter bw2io.importers.ExcelLCIAImporter bw2io.importers.MultiOutputEcospold1Importer bw2io.importers.NoIntegerCodesEcospold1Importer bw2io.importers.SimaProCSVImporter bw2io.importers.SimaProLCIACSVImporter bw2io.importers.SingleOutputEcospold1Importer bw2io.importers.SingleOutputEcospold2Importer Package Contents ---------------- .. py:class:: CSVImporter(filepath) Bases: :py:obj:`ExcelImporter` .. autoapi-inheritance-diagram:: bw2io.importers.CSVImporter :parts: 1 :private-bases: Generic CSV importer .. py:attribute:: extractor .. py:attribute:: format :value: 'CSV' .. py:class:: CSVLCIAImporter(filepath, name, description, unit, **metadata) Bases: :py:obj:`ExcelLCIAImporter` .. autoapi-inheritance-diagram:: bw2io.importers.CSVLCIAImporter :parts: 1 :private-bases: Generic CSV LCIA importer .. py:attribute:: extractor .. py:attribute:: format :value: 'CSV' .. py:class:: EcoinventLCIAImporter Bases: :py:obj:`bw2io.importers.base_lcia.LCIAImporter` .. autoapi-inheritance-diagram:: bw2io.importers.EcoinventLCIAImporter :parts: 1 :private-bases: Base class for format-specific importers. Defines workflow for applying strategies. .. py:method:: add_rationalize_method_names_strategy() .. py:method:: separate_methods() Separate the list of CFs into distinct methods .. py:attribute:: applied_strategies :value: [] .. py:attribute:: strategies .. py:class:: Ecospold1LCIAImporter(filepath, biosphere=None) Bases: :py:obj:`bw2io.importers.base_lcia.LCIAImporter` .. autoapi-inheritance-diagram:: bw2io.importers.Ecospold1LCIAImporter :parts: 1 :private-bases: .. py:attribute:: data .. py:attribute:: format :value: 'Ecospold1 LCIA' .. py:attribute:: start .. py:class:: Ecospold2BiosphereImporter(name='biosphere3', version='3.9') Bases: :py:obj:`bw2io.importers.base_lci.LCIImporter` .. autoapi-inheritance-diagram:: bw2io.importers.Ecospold2BiosphereImporter :parts: 1 :private-bases: .. py:method:: extract(version) .. py:attribute:: data .. py:attribute:: db_name .. py:attribute:: format :value: 'Ecoinvent XML' .. py:attribute:: strategies .. py:class:: ExcelImporter(filepath) Bases: :py:obj:`bw2io.importers.base_lci.LCIImporter` .. autoapi-inheritance-diagram:: bw2io.importers.ExcelImporter :parts: 1 :private-bases: Generic Excel importer. See the `generic Excel example spreadsheet `__. Excel spreadsheet should follow the following format: :: Project parameters , , , metadata Database, , Parameters , , , metadata Activity, , Exchanges , , , , , , 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. .. py:method:: get_activity(sn, ws) .. py:method:: get_database(data) .. py:method:: get_database_parameters(data) .. py:method:: 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``. .. py:method:: get_metadata_section(sn, ws, index=0, transform=True) .. py:method:: 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. .. py:method:: process_activities(data) Take list of `(sheet names, raw data)` and process it. .. py:method:: write_activity_parameters(data=None, delete_existing=True) .. py:method:: write_database(**kwargs) Same as base ``write_database`` method, but ``activate_parameters`` is True by default. .. py:method:: write_database_parameters(activate_parameters=True, delete_existing=True) Same as base ``write_database_parameters`` method, but ``activate_parameters`` is True by default. .. py:attribute:: data .. py:attribute:: extractor .. py:attribute:: format :value: 'Excel' .. py:attribute:: start .. py:attribute:: strategies .. py:class:: ExcelLCIAImporter(filepath, name, description, unit, **metadata) Bases: :py:obj:`bw2io.importers.base_lcia.LCIAImporter` .. autoapi-inheritance-diagram:: bw2io.importers.ExcelLCIAImporter :parts: 1 :private-bases: Generic Excel LCIA importer. See the `documentation `__. .. py:attribute:: data .. py:attribute:: extractor .. py:attribute:: format :value: 'Excel' .. py:attribute:: strategies .. py:class:: MultiOutputEcospold1Importer(*args, **kwargs) Bases: :py:obj:`SingleOutputEcospold1Importer` .. autoapi-inheritance-diagram:: bw2io.importers.MultiOutputEcospold1Importer :parts: 1 :private-bases: Import and process mutli-output datasets in the ecospold 1 format. Works the same as the single-output importer, but first allocates multioutput datasets. .. py:class:: NoIntegerCodesEcospold1Importer(*args, **kwargs) Bases: :py:obj:`SingleOutputEcospold1Importer` .. autoapi-inheritance-diagram:: bw2io.importers.NoIntegerCodesEcospold1Importer :parts: 1 :private-bases: 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 :param \* *filepath*: Either a file or directory. :param \* *db_name*: Name of database to create. .. py:class:: SimaProCSVImporter(filepath, name=None, delimiter=';', encoding='latin-1', normalize_biosphere=True, biosphere_db=None) Bases: :py:obj:`bw2io.importers.base_lci.LCIImporter` .. autoapi-inheritance-diagram:: bw2io.importers.SimaProCSVImporter :parts: 1 :private-bases: .. py:method:: get_db_name() .. py:method:: match_ecoinvent2(db_name) .. py:method:: write_database(data=None, name=None, *args, **kwargs) .. py:attribute:: format :value: 'SimaPro CSV' .. py:attribute:: start .. py:attribute:: strategies .. py:class:: SimaProLCIACSVImporter(filepath, biosphere=None, delimiter=';', encoding='latin-1', normalize_biosphere=True) Bases: :py:obj:`bw2io.importers.base_lcia.LCIAImporter` .. autoapi-inheritance-diagram:: bw2io.importers.SimaProLCIACSVImporter :parts: 1 :private-bases: .. py:attribute:: data .. py:attribute:: format :value: 'SimaPro CSV LCIA' .. py:attribute:: start .. py:class:: SingleOutputEcospold1Importer(filepath, db_name, use_mp=True, extractor=Ecospold1DataExtractor) Bases: :py:obj:`bw2io.importers.base_lci.LCIImporter` .. autoapi-inheritance-diagram:: bw2io.importers.SingleOutputEcospold1Importer :parts: 1 :private-bases: 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 :param \* *filepath*: Either a file or directory. :param \* *db_name*: Name of database to create. .. py:attribute:: db_name .. py:attribute:: format :value: 'Ecospold1' .. py:attribute:: start .. py:attribute:: strategies .. py:class:: SingleOutputEcospold2Importer(dirpath, db_name, extractor=Ecospold2DataExtractor, use_mp=True, signal=None, reparametrize_lognormals=False) Bases: :py:obj:`bw2io.importers.base_lci.LCIImporter` .. autoapi-inheritance-diagram:: bw2io.importers.SingleOutputEcospold2Importer :parts: 1 :private-bases: Base class for format-specific importers. Defines workflow for applying strategies. Takes a database name (string) as initialization parameter. Initializes the SingleOutputEcospold2Importer class instance. :param dirpath: Path to the directory containing the ecospold2 file. :type dirpath: str :param db_name: Name of the LCI database. :type db_name: str :param extractor: Class for extracting data from the ecospold2 file, by default Ecospold2DataExtractor. :type extractor: class :param use_mp: Flag to indicate whether to use multiprocessing, by default True. :type use_mp: bool :param signal: Object to indicate the status of the import process, by default None. :type signal: object :param reparametrize_lognormals: Flag to indicate if lognormal distributions for exchanges should be reparametrized such that the mean value of the resulting distribution meets the amount defined for the exchange. :type reparametrize_lognormals: bool .. py:attribute:: db_name .. py:attribute:: dirpath .. py:attribute:: format :value: 'Ecospold2' .. py:attribute:: signal .. py:attribute:: start .. py:attribute:: strategies