LCA-ActivityBrowser / activity-browser

GUI for brightway2
GNU Lesser General Public License v3.0
135 stars 52 forks source link

Import Ecospold 2 from OpenLCA export (converted with openLCA converter) #787

Closed Ldegroot34 closed 2 years ago

Ldegroot34 commented 2 years ago

I am having an issue importing 'Ecospold2.7z' files. My goal is to transfer a data file from OpenLCA (ILCD format or .zolca) to AB, for that I have used the OpenLCA converter https://www.openlca.org/format-converter/. But while importing the 'Ecospold2.7z' file into AB I get the error: 'The archive '....' is corrupted, please remove and re-download it.'

Does anyone have experience with importing OpenLCA or a possible solution? That would be very helpful.

Thanks in advance, Luce

marc-vdm commented 2 years ago

Hi Luce,

Please open an issue with Brightway2-io, we depend on their library for importing data into AB.

Ldegroot34 commented 2 years ago

thank you!

haasad commented 2 years ago

Hi @Ldegroot34,

can you quickly verify if the file you're trying to import is a valid .7z file? For example by opening it with an unarchive program? Maybe there's already something going wrong with the converter step.

And is the error message you posted literal? I.e does it really say The archive '....'? This could indicate that something is wrong with the path.

See also #775

I don't think it's bw2io related as the error message is triggered during the attempt to unarchive in the AB: https://github.com/LCA-ActivityBrowser/activity-browser/blob/dd855d33f0fe9321a379b0780d29fca70d654598/activity_browser/ui/wizards/db_import_wizard.py#L660-L663

haasad commented 2 years ago

you can also run py7zr t <path/to/your/file> in a terminal with the activity-browser env activated to test if it's a valid .7z file

marc-vdm commented 2 years ago

EcoSpold02.zip (the 7z is zipped as GH doesn't allow 7z) @haasad I got the file before from @Ldegroot34, it's not actually corrupt but AB is giving that error. I was able to unpack, but then I don't recognize the internal file structure, nor does AB. Looks to me like it's not the same as what BW is expecting as ecospold2, but I'm not sure that BW is doing something not in-line with the format or that the converter from openLCA is doing something that BW is not expecting.

haasad commented 2 years ago

I did the following:

Everything is Ok

- unarchive `py7zr x EcoSpold02.7z`
- check the structure:

tree EcoSpold02 EcoSpold02 ├── Content │   └── MasterData │   ├── Companies.xml │   ├── CompanyCodes.xml │   ├── Compartments.xml │   ├── Contexts.xml │   ├── Geographies.xml │   ├── Languages.xml │   ├── MacroEconomicScenarios.xml │   ├── Parameters.xml │   ├── Properties.xml │   ├── SystemModels.xml │   ├── Tags.xml │   └── Units.xml ├── log.html ├── Pictures └── Schemas ├── Child │   ├── EcoSpold02ChildActivity.xsd │   ├── EcoSpold02ChildDataTypes.xsd │   ├── EcoSpold02ChildFlowData.xsd │   └── EcoSpold02ChildMetaInformation.xsd ├── EcoSpold02Activity.xsd ├── EcoSpold02DataTypes.xsd ├── EcoSpold02FlowData.xsd ├── EcoSpold02MetaInformation.xsd ├── EcoSpold02.xsd ├── MasterData │   ├── EcoSpold02ActivityNames.xsd │   ├── EcoSpold02Classification.xsd │   ├── EcoSpold02Companies.xsd │   ├── EcoSpold02Compartments.xsd │   ├── EcoSpold02Context.xsd │   ├── EcoSpold02ElementaryExchanges.xsd │   ├── EcoSpold02Geographies.xsd │   ├── EcoSpold02IntermediateExchanges.xsd │   ├── EcoSpold02Languages.xsd │   ├── EcoSpold02MacroEconomicScenarios.xsd │   ├── EcoSpold02Parameters.xsd │   ├── EcoSpold02Persons.xsd │   ├── EcoSpold02Properties.xsd │   ├── EcoSpold02Sources.xsd │   ├── EcoSpold02SystemModels.xsd │   ├── EcoSpold02Tags.xsd │   └── EcoSpold02Units.xsd └── XmlNamespace.xsd

6 directories, 40 files



Observations:
- there's not a single `.spold`-file in the archive, only some schemas
- the `log.html` file, which is probably the log file generated by the converter tool is over 3000 lines with mostly errors about missing locations
- based on the github activity, https://github.com/GreenDelta/olca-converter has last been updated in October 2015, so I'm surprised it's running at all :-)
- you can try your luck with opening an issue there, but this looks to me like a tool that's not supported anymore and there's not a lot we can do from the AB side
haasad commented 2 years ago

Side note: I get an bw2io.errors.WrongDatabase: Activity database must be abcde, but set() was also found error in the AB, not the archive corrupted message. But that's mostly irrelevant as there's not spold files to extract in the archive in the first place.

Ldegroot34 commented 2 years ago

okay, thank you for sorting it out. It makes sense now. Do you by chance have advice for a different way to convert OpenLCA files?

haasad commented 2 years ago

No idea unfortunately, but unless you can find some info on the internet or in a paper where somebody describes such a procedure I fear you'd have to write/invent it yourself. I would try and ask in https://github.com/GreenDelta/olca-converter, maybe the openLCA guys know of a way :man_shrugging:

iamihgam commented 2 years ago

Might this link be of help from openLCA forum : https://ask.openlca.org/3648/eugeos-in-ecospold02-format openLCA stopped supporting export to ecospold2 format ~since last year due to changes in ecoeditor .

cyrillefrancois commented 1 year ago

Hello, I have developed a package to import data from OLCA to Brightway2. https://github.com/cyrillefrancois/openlca2bw This should allow you to transfer your database. Nonetheless, it's still underdevelopment, and it works only for data related to the ecoinvent database and without multioutputs processes. This package works for rather a ILCD .zip (json) file or an IPC connexion.