cyrillefrancois / openlca2bw

Other
9 stars 5 forks source link

USLCI v2.0.0 importing failed. Currently working with USLCI v1.10.3 #7

Closed tjlca closed 7 months ago

tjlca commented 8 months ago

uslci_fy23_q1_02_olca1_10_3 v1.10.3 was imported successfully with openlca2bw.

uslci_fy23_q2_01_olca2_0_0_json_ld was not imported with openlca2bw. Error message posted below.

 return self._engine.get_loc(casted_key)

  File index.pyx:152 in pandas._libs.index.IndexEngine.get_loc

  File index.pyx:181 in pandas._libs.index.IndexEngine.get_loc

  File pandas/_libs/hashtable_class_helper.pxi:7080 in pandas._libs.hashtable.PyObjectHashTable.get_item

  File pandas/_libs/hashtable_class_helper.pxi:7088 in pandas._libs.hashtable.PyObjectHashTable.get_item

KeyError: 'e2f7001e-a331-4fc7-8052-c0b9bcf6a05f'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):

  Cell In[7], line 1
    olca2bw.load_openLCA_Json(path_zip=Zip_path,

  File ~/miniconda3/envs/bwuslci/lib/python3.10/site-packages/openlca2bw/main.py:263 in load_openLCA_Json
    json_db.unit_conv = json_db.unit_convert_factor()

  File ~/miniconda3/envs/bwuslci/lib/python3.10/site-packages/openlca2bw/extract.py:52 in unit_convert_factor
    ref_u = normalize_units(flow_ref_unit.loc[return_attribute(u_group,('defaultFlowProperty','@id'))].values[0])

  File ~/miniconda3/envs/bwuslci/lib/python3.10/site-packages/pandas/core/indexing.py:1153 in __getitem__
    return self._getitem_axis(maybe_callable, axis=axis)

  File ~/miniconda3/envs/bwuslci/lib/python3.10/site-packages/pandas/core/indexing.py:1393 in _getitem_axis
    return self._get_label(key, axis=axis)

  File ~/miniconda3/envs/bwuslci/lib/python3.10/site-packages/pandas/core/indexing.py:1343 in _get_label
    return self.obj.xs(label, axis=axis)

  File ~/miniconda3/envs/bwuslci/lib/python3.10/site-packages/pandas/core/generic.py:4236 in xs
    loc = index.get_loc(key)

  File ~/miniconda3/envs/bwuslci/lib/python3.10/site-packages/pandas/core/indexes/base.py:3797 in get_loc
    raise KeyError(key) from err

KeyError: 'e2f7001e-a331-4fc7-8052-c0b9bcf6a05f'

The latest version of ULSCI is for openLCA v2.0 and that introduced something new which is breaking the openLCA2BW importer. We need to know what changes were introduced so that this problem does not recur in the future.

cyrillefrancois commented 8 months ago

Did you try the new version of the package ? Because with OpenLCA 2.x some json keys names have changed. The new version should work better. pip install openlca2bw==0.0.0