Ecoinvent3.2 Import Error

50 views
Skip to first unread message

Jim Levis

unread,
Aug 22, 2016, 4:21:48 PM8/22/16
to brightway2
So I tried to import the Ecoinvent3.2 Cut-off database, just like the example code on the start page (https://brightwaylca.org/), but I had a lot of unlinked exchanges in step 5, which I believe led to an InvalidExchange error in step 6. Does anyone have any experience with this? 

In the database folder (ECOINV~2.2-C), I have a "datasets" folder and a "MasterData" folder. Is there something I need to do with the MasterData folder?

Thanks,
Jim

Code Below:
from brightway2 import *
In [2]:
fp = "E:\GOOGLE~1\ECOINV~1\ECOINV~2.2-C\datasets"
In [3]:
ei = SingleOutputEcospold2Importer(fp, "ecoinvent 3.2 conseq")
Extracting XML data from 12916 datasets
Extracted 12916 datasets in 19.52 seconds
In [4]:
ei.apply_strategies()
Applying strategy: normalize_units
Applying strategy: remove_zero_amount_coproducts
Applying strategy: remove_zero_amount_inputs_with_no_activity
Applying strategy: remove_unnamed_parameters
Applying strategy: es2_assign_only_product_with_amount_as_reference_product
Applying strategy: assign_single_product_as_activity
Applying strategy: create_composite_code
Applying strategy: drop_unspecified_subcategories
Applying strategy: link_biosphere_by_flow_uuid
Applying strategy: link_internal_technosphere_by_composite_code
Applying strategy: delete_exchanges_missing_activity
Applying strategy: delete_ghost_exchanges
Applying strategy: nuncertainty
Applied 13 strategies in 2.35 seconds
In [5]:
ei.statistics()
12916 datasets
459268 exchanges
343020 unlinked exchanges
  Type biosphere: 949 unique unlinked exchanges
Out[5]:
(12916, 459268, 343020)
In [6]:
ei.write_database()
Writing activities to SQLite3 database:
0%                          100%
[                              ]
---------------------------------------------------------------------------
InvalidExchange                           Traceback (most recent call last)
<ipython-input-6-9500e044bad1> in <module>()
----> 1 ei.write_database()

C:\bw2-python\envs\bw2\lib\site-packages\bw2io\importers\base_lci.py in write_database(self, data, name, overwrite, backend, **kwargs)
    109                 db.register(format=self.format, **kwargs)
    110         existing.update(data)
--> 111         db.write(existing)
    112         print("Created database: {}".format(db.name))
    113         return db

C:\bw2-python\envs\bw2\lib\site-packages\bw2data\project.py in writable_project(wrapped, instance, args, kwargs)
    383     if projects.read_only:
    384         raise ReadOnlyProject(READ_ONLY_PROJECT)
--> 385     return wrapped(*args, **kwargs)

C:\bw2-python\envs\bw2\lib\site-packages\bw2data\backends\peewee\database.py in write(self, data, process)
    243         if data:
    244             try:
--> 245                 self._efficient_write_many_data(data)
    246             except:
    247                 # Purge all data from database, then reraise

C:\bw2-python\envs\bw2\lib\site-packages\bw2data\backends\peewee\database.py in _efficient_write_many_data(self, data, indices)
    165                 for exchange in ds.get('exchanges', []):
    166                     if 'input' not in exchange or 'amount' not in exchange:
--> 167                         raise InvalidExchange
    168                     if 'type' not in exchange:
    169                         raise UntypedExchange

InvalidExchange: 
Reply all
Reply to author
Forward
0 new messages