Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

problem with excel importer #1021

Closed
simb-sdu opened this issue Aug 25, 2023 · 6 comments
Closed

problem with excel importer #1021

simb-sdu opened this issue Aug 25, 2023 · 6 comments

Comments

@simb-sdu
Copy link

simb-sdu commented Aug 25, 2023

image

The excel importer asks me to identify the database Cut-off_DK_BAU. However that is the name of the databse i want to import! So it should be able to dientify itself.

As you can see in the following screenshot, all exchanges gets the db name from cell B1 which ahs the value Cut-off_DK_BAU
image

Cant figure out what triggers this issue - which means i cannot import my excel databse. Yesterday I made a very small test databse with just one exchange, and that worked fine

@simb-sdu
Copy link
Author

could it be a memory problem, since it doesn't work with larger files??

@Zoophobus
Copy link
Contributor

Hi @simb-sdu,

I think this is an unrelated issue to what I had, I was getting segmentation faults from an issue that I think is related to multi-threading. Would it be possible to share your database, so that it's possible to see where the problem is starting?

KR,
J

@simb-sdu
Copy link
Author

Hi J

Plase send me an email on simb@igt.sdu.dk and i will share the excel datebase. it's my colleagues data so I dont think i can put it publicly

Hi @simb-sdu,

I think this is an unrelated issue to what I had, I was getting segmentation faults from an issue that I think is related to multi-threading. Would it be possible to share your database, so that it's possible to see where the problem is starting?

KR, J

@Zoophobus
Copy link
Contributor

Hi @simb-sdu you can use this address kidnerjh@vuw.leidenuniv.nl

@simb-sdu
Copy link
Author

simb-sdu commented Aug 25, 2023

I solved the problem! edit: thanks for answering @Zoophobus, it somehow helped get my "diagnozing" in the right direction

It appears that my excel file had some wrong values for a few locations and units. however this was impossible to spot via activity-browser. i found it by importing manually in brigthway with the following code


import bw2data as bd
import bw2calc as bc
import bw2io as bi
#import bw_processing as bwp
import numpy as np
from pathlib import Path
import pandas as pd
bd.projects.set_current('sarah-ei391')



imp = bi.ExcelImporter("/home/simb/Nextcloud/Cut-off_DK_BAU.xlsx")
imp.apply_strategies()
imp.match_database("cutoff391", fields=('name','unit','location', 'reference product'))
imp.match_database(fields=('name', 'unit', 'location'))
imp.statistics()
imp.write_excel()

imp.write_database()

this gave the error
1 unlinked exchanges Type technosphere: 1 unique unlinked exchanges Wrote matching file to: /home/simb/.local/share/Brightway3/sarah-ei391.e7b311ea4751b039a2d93e8d91891004/output/db-matching-Cut-off_DK_BAU.xlsx Writing activities to SQLite3 database: 0% [######## ] 100% | ETA: 00:00:01Traceback (most recent call last): File "/home/simb/Nextcloud/sarah case study/excelimport.py", line 21, in <module> imp.write_database() File "/home/simb/miniconda3/envs/ab/lib/python3.9/site-packages/bw2io/importers/excel.py", line 277, in write_database super(ExcelImporter, self).write_database(**kwargs) File "/home/simb/miniconda3/envs/ab/lib/python3.9/site-packages/bw2io/importers/base_lci.py", line 269, in write_database db.write(existing) File "/home/simb/miniconda3/envs/ab/lib/python3.9/site-packages/bw2data/project.py", line 358, in writable_project return wrapped(*args, **kwargs) File "/home/simb/miniconda3/envs/ab/lib/python3.9/site-packages/bw2data/backends/peewee/database.py", line 260, in write self._efficient_write_many_data(data) File "/home/simb/miniconda3/envs/ab/lib/python3.9/site-packages/bw2data/backends/peewee/database.py", line 204, in _efficient_write_many_data exchanges, activities = self._efficient_write_dataset( File "/home/simb/miniconda3/envs/ab/lib/python3.9/site-packages/bw2data/backends/peewee/database.py", line 156, in _efficient_write_dataset raise InvalidExchange bw2data.errors.InvalidExchange

eventually i opened the log file Wrote matching file to: /home/simb/.local/share/Brightway3/sarah-ei391.e7b311ea4751b039a2d93e8d91891004/output/db-matching-Cut-off_DK_BAU.xlsx and here the invalid exchanges were highlighted with red. There I could see that the unit for electricity was in megajoule, and not kilowatt hour. hence it could not match to the ecoinvent dataset where it is given in kilowatt hour

@marc-vdm
Copy link
Member

marc-vdm commented Aug 28, 2023 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants