ecospold2 import fails: no geography

Issue #18 new
Pommes Papst
created an issue

I am trying to import an ecospold2 file but I get the following error:

Extracting ecospold2 files: Traceback (most recent call last): File "<input>", line 4, in <module> File "C:\Users\user\AppData\Local\Programs\Python\Python36\lib\site-packages\bw2io\importers\ecospold2.py", line 62, in init self.data = extractor.extract(dirpath, db_name) File "<input>", line 4, in extract File "C:\Users\user\AppData\Local\Programs\Python\Python36\lib\site-packages\bw2io\extractors\ecospold2.py", line 99, in extract data.append(cls.extract_activity(dirpath, filename, db_name)) File "C:\Users\user\AppData\Local\Programs\Python\Python36\lib\site-packages\bw2io\extractors\ecospold2.py", line 135, in extract_activity stem.activityDescription.geography, "comment"))), File "src\lxml\objectify.pyx", line 230, in lxml.objectify.ObjectifiedElement.getattr File "src\lxml\objectify.pyx", line 450, in lxml.objectify._lookupChildOrRaise AttributeError: no such child: {http://www.EcoInvent.org/EcoSpold02}geography

I attached the .spold file. The error might appear because the file was originally a ILCD file which I converted to ecospold2 using the OpenLCA converter.

Comments (7)

  1. Pommes Papst reporter

    Update: error does not occur, if I export an ecoinvent activity as ILCD, convert it to ecospold2, and try to import it into brightway2. Seems, the error occurs because I try to import a custom process with mal-defined geography?

  2. Chris Mutel repo owner

    The output file is not valid ecospold2. It is not just the location data, but a lot of different of elements:

    8eb88a18-9ad1-4382-a1d1-99cec36e6a58.spold:12: element timePeriod: Schemas validity error : Element '{http://www.EcoInvent.org/EcoSpold02}timePeriod': This element is not expected. Expected is one of ( {http://www.EcoInvent.org/EcoSpold02}classification, {http://www.EcoInvent.org/EcoSpold02}geography ).
    8eb88a18-9ad1-4382-a1d1-99cec36e6a58.spold:45: element parameter: Schemas validity error : Element '{http://www.EcoInvent.org/EcoSpold02}parameter', attribute 'id': The attribute 'id' is not allowed.
    8eb88a18-9ad1-4382-a1d1-99cec36e6a58.spold:45: element parameter: Schemas validity error : Element '{http://www.EcoInvent.org/EcoSpold02}parameter': The attribute 'parameterId' is required but missing.
    8eb88a18-9ad1-4382-a1d1-99cec36e6a58.spold:48: element parameter: Schemas validity error : Element '{http://www.EcoInvent.org/EcoSpold02}parameter', attribute 'id': The attribute 'id' is not allowed.
    8eb88a18-9ad1-4382-a1d1-99cec36e6a58.spold:48: element parameter: Schemas validity error : Element '{http://www.EcoInvent.org/EcoSpold02}parameter': The attribute 'parameterId' is required but missing.
    8eb88a18-9ad1-4382-a1d1-99cec36e6a58.spold:51: element parameter: Schemas validity error : Element '{http://www.EcoInvent.org/EcoSpold02}parameter', attribute 'id': The attribute 'id' is not allowed.
    8eb88a18-9ad1-4382-a1d1-99cec36e6a58.spold:51: element parameter: Schemas validity error : Element '{http://www.EcoInvent.org/EcoSpold02}parameter': The attribute 'parameterId' is required but missing.
    8eb88a18-9ad1-4382-a1d1-99cec36e6a58.spold:54: element parameter: Schemas validity error : Element '{http://www.EcoInvent.org/EcoSpold02}parameter', attribute 'id': The attribute 'id' is not allowed.
    8eb88a18-9ad1-4382-a1d1-99cec36e6a58.spold:54: element parameter: Schemas validity error : Element '{http://www.EcoInvent.org/EcoSpold02}parameter': The attribute 'parameterId' is required but missing.
    8eb88a18-9ad1-4382-a1d1-99cec36e6a58.spold:57: element parameter: Schemas validity error : Element '{http://www.EcoInvent.org/EcoSpold02}parameter', attribute 'id': The attribute 'id' is not allowed.
    8eb88a18-9ad1-4382-a1d1-99cec36e6a58.spold:57: element parameter: Schemas validity error : Element '{http://www.EcoInvent.org/EcoSpold02}parameter': The attribute 'parameterId' is required but missing.
    8eb88a18-9ad1-4382-a1d1-99cec36e6a58.spold:60: element parameter: Schemas validity error : Element '{http://www.EcoInvent.org/EcoSpold02}parameter', attribute 'id': The attribute 'id' is not allowed.
    8eb88a18-9ad1-4382-a1d1-99cec36e6a58.spold:60: element parameter: Schemas validity error : Element '{http://www.EcoInvent.org/EcoSpold02}parameter': The attribute 'parameterId' is required but missing.
    8eb88a18-9ad1-4382-a1d1-99cec36e6a58.spold:63: element parameter: Schemas validity error : Element '{http://www.EcoInvent.org/EcoSpold02}parameter', attribute 'id': The attribute 'id' is not allowed.
    8eb88a18-9ad1-4382-a1d1-99cec36e6a58.spold:63: element parameter: Schemas validity error : Element '{http://www.EcoInvent.org/EcoSpold02}parameter': The attribute 'parameterId' is required but missing.
    8eb88a18-9ad1-4382-a1d1-99cec36e6a58.spold:66: element parameter: Schemas validity error : Element '{http://www.EcoInvent.org/EcoSpold02}parameter', attribute 'id': The attribute 'id' is not allowed.
    8eb88a18-9ad1-4382-a1d1-99cec36e6a58.spold:66: element parameter: Schemas validity error : Element '{http://www.EcoInvent.org/EcoSpold02}parameter': The attribute 'parameterId' is required but missing.
    8eb88a18-9ad1-4382-a1d1-99cec36e6a58.spold:69: element parameter: Schemas validity error : Element '{http://www.EcoInvent.org/EcoSpold02}parameter', attribute 'id': The attribute 'id' is not allowed.
    8eb88a18-9ad1-4382-a1d1-99cec36e6a58.spold:69: element parameter: Schemas validity error : Element '{http://www.EcoInvent.org/EcoSpold02}parameter': The attribute 'parameterId' is required but missing.
    8eb88a18-9ad1-4382-a1d1-99cec36e6a58.spold:72: element parameter: Schemas validity error : Element '{http://www.EcoInvent.org/EcoSpold02}parameter', attribute 'id': The attribute 'id' is not allowed.
    8eb88a18-9ad1-4382-a1d1-99cec36e6a58.spold:72: element parameter: Schemas validity error : Element '{http://www.EcoInvent.org/EcoSpold02}parameter': The attribute 'parameterId' is required but missing.
    8eb88a18-9ad1-4382-a1d1-99cec36e6a58.spold:75: element parameter: Schemas validity error : Element '{http://www.EcoInvent.org/EcoSpold02}parameter', attribute 'id': The attribute 'id' is not allowed.
    8eb88a18-9ad1-4382-a1d1-99cec36e6a58.spold:75: element parameter: Schemas validity error : Element '{http://www.EcoInvent.org/EcoSpold02}parameter': The attribute 'parameterId' is required but missing.
    8eb88a18-9ad1-4382-a1d1-99cec36e6a58.spold:78: element parameter: Schemas validity error : Element '{http://www.EcoInvent.org/EcoSpold02}parameter', attribute 'id': The attribute 'id' is not allowed.
    8eb88a18-9ad1-4382-a1d1-99cec36e6a58.spold:78: element parameter: Schemas validity error : Element '{http://www.EcoInvent.org/EcoSpold02}parameter': The attribute 'parameterId' is required but missing.
    8eb88a18-9ad1-4382-a1d1-99cec36e6a58.spold:81: element parameter: Schemas validity error : Element '{http://www.EcoInvent.org/EcoSpold02}parameter', attribute 'id': The attribute 'id' is not allowed.
    8eb88a18-9ad1-4382-a1d1-99cec36e6a58.spold:81: element parameter: Schemas validity error : Element '{http://www.EcoInvent.org/EcoSpold02}parameter': The attribute 'parameterId' is required but missing.
    8eb88a18-9ad1-4382-a1d1-99cec36e6a58.spold:84: element parameter: Schemas validity error : Element '{http://www.EcoInvent.org/EcoSpold02}parameter', attribute 'id': The attribute 'id' is not allowed.
    8eb88a18-9ad1-4382-a1d1-99cec36e6a58.spold:84: element parameter: Schemas validity error : Element '{http://www.EcoInvent.org/EcoSpold02}parameter': The attribute 'parameterId' is required but missing.
    8eb88a18-9ad1-4382-a1d1-99cec36e6a58.spold:87: element parameter: Schemas validity error : Element '{http://www.EcoInvent.org/EcoSpold02}parameter', attribute 'id': The attribute 'id' is not allowed.
    8eb88a18-9ad1-4382-a1d1-99cec36e6a58.spold:87: element parameter: Schemas validity error : Element '{http://www.EcoInvent.org/EcoSpold02}parameter': The attribute 'parameterId' is required but missing.
    8eb88a18-9ad1-4382-a1d1-99cec36e6a58.spold:97: element dataEntryBy: Schemas validity error : Element '{http://www.EcoInvent.org/EcoSpold02}dataEntryBy': The attribute 'personId' is required but missing.
    8eb88a18-9ad1-4382-a1d1-99cec36e6a58.spold:97: element dataEntryBy: Schemas validity error : Element '{http://www.EcoInvent.org/EcoSpold02}dataEntryBy': The attribute 'personName' is required but missing.
    8eb88a18-9ad1-4382-a1d1-99cec36e6a58.spold:97: element dataEntryBy: Schemas validity error : Element '{http://www.EcoInvent.org/EcoSpold02}dataEntryBy': The attribute 'personEmail' is required but missing.
    8eb88a18-9ad1-4382-a1d1-99cec36e6a58.spold:98: element dataGeneratorAndPublication: Schemas validity error : Element '{http://www.EcoInvent.org/EcoSpold02}dataGeneratorAndPublication': The attribute 'personId' is required but missing.
    8eb88a18-9ad1-4382-a1d1-99cec36e6a58.spold:98: element dataGeneratorAndPublication: Schemas validity error : Element '{http://www.EcoInvent.org/EcoSpold02}dataGeneratorAndPublication': The attribute 'personName' is required but missing.
    8eb88a18-9ad1-4382-a1d1-99cec36e6a58.spold:98: element dataGeneratorAndPublication: Schemas validity error : Element '{http://www.EcoInvent.org/EcoSpold02}dataGeneratorAndPublication': The attribute 'personEmail' is required but missing.
    8eb88a18-9ad1-4382-a1d1-99cec36e6a58.spold:99: element fileAttributes: Schemas validity error : Element '{http://www.EcoInvent.org/EcoSpold02}fileAttributes': The attribute 'majorRevision' is required but missing.
    8eb88a18-9ad1-4382-a1d1-99cec36e6a58.spold:99: element fileAttributes: Schemas validity error : Element '{http://www.EcoInvent.org/EcoSpold02}fileAttributes': The attribute 'minorRevision' is required but missing.
    8eb88a18-9ad1-4382-a1d1-99cec36e6a58.spold fails to validate
    

    Unfortunately, there is not much that Brightway can do here. If you expect this to be a major problem, the only real solution would be to write a more lenient extractor that provides default values for missing attributes (e.g. GLO for location).

  3. Pommes Papst reporter

    Thanks a lot for the hint to xmllint!

    Concerning my problem: I found a work around. I will describe it here. Maybe you can make it a section in your documentation or something.

    Aim: Export a model from GaBi into Brightway2.

    Things I've tried:

    Export as tsx -> import in Brightway2 : import of tsx not supported in Brightway2

    Export as ecospold1 -> import in Brightway2: not an option because ecospold1 does not support parameters

    Export as ILCD -> import in Brightway2: import of ILCD not supported in Brightway2

    Export as ILCD -> convert to ecospold2 using OpenLCA conversion tool -> import in brightway2: import crashes with above errors (only for custom activities, ecoinvent activities work)

    Export as ILCD -> import into OpenLCA -> export as ecospold2 -> import in brightway2: works!

    Looks like OpenLCA import adds the missing attributes. Also export from OpenLCA seems to get the attribute naming right (parameterId instead of id), contrary to the conversion tool. Unfortunately there is no possibility in GaBi to export ecospold2. Would make things a lot easier...

  4. Pommes Papst reporter

    Just realized that the import worked but the mathematical relations in the parameters were not imported. Is there a way to keep the mathematical relations?

  5. Chris Mutel repo owner

    It's on the roadmap, and needed for current projects, so it is coming - but is not there yet. Shouldn't be too much of a change, you are welcome to look at the parameter extraction already in bw2io and extend it :)

  6. Log in to comment