Comments (5)
The ExcelImporter
is incorrectly reading the code
value as an integer:
>>> import bw2io as bi
>>> excel = bi.ExcelImporter("lci_bw_minim.xlsx")
>>> excel.apply_strategies()
>>> excel.data[0]['code']
41000000
>>> type(excel.data[0]['code'])
int
I don't know how this breaks stuff, but it is definitely the problem. Luckily it is easy to fix:
def codes_as_strings(data):
for ds in data:
ds['code'] = str(ds['code'])
return data
excel.apply_strategy(codes_as_strings)
BTW, to import the sample database I had to relabel the "product" column:
def relabel_products(data):
for ds in data:
for exc in ds['exchanges']:
exc['reference product'] = exc['product']
return data
excel.apply_strategy(relabel_products)
I can then do LCA calculations and get LCIA scores.
from brightway2-io.
Dear Christopher,
Thank you so much for your quick response.
Your solution works fine! 🙂
Kind regards,
Daniel
from brightway2-io.
Hi again,
Just a small edit to the answer. To make it work on my side I needed to send the code_as_strings as a list since apply_strategies expects such argument type:
excel.apply_strategy([codes_as_strings])
from brightway2-io.
@danielPclos apply_strategy
takes a single function, apply_strategies
takes a list of functions. In you last comment you used both terms :)
from brightway2-io.
Thanks @cmutel, I'm a bit blind so now I understand why was I getting inconsistent behavior due to interchange of these 2 methods. :)
from brightway2-io.
Related Issues (20)
- Some extractor methods do not have the `use_mp` flag implemented, causing them to fail. HOT 1
- [BW2 legacy] Error with easy ecoinvent biosphere flows/LCI/LCIA import of bw2io version 0.8.11 HOT 3
- SimaPro CSV importer doesn't fix broken uncertainty values HOT 8
- US EEIO import is broken
- [Discussion/Feature request] Adding `database` field to Linking Iterables by field on import HOT 2
- Excel file import - AttributeError: 'int' object has no attribute 'lower' HOT 1
- Few type hints not compatible with python 3.9 & python 3.8 HOT 1
- Encoding erorr when running `import_ecoinvent_release` on `v3.10` HOT 3
- Backport fix for "chemical formulas" from 0.9.DEV7 to 0.8.X ? HOT 1
- AttributeError in add_missing_cfs(): 'ExcelLCIAImporter' object has no attribute 'biosphere_name' HOT 1
- Importing in BW processes written in SP HOT 2
- errors importing exiobase in monetary units HOT 1
- KeyError in IOTable backend HOT 2
- update README to use cookiecutterlib format
- Configurable multiprocessing for large data import (Ecoinvent ecospold2) HOT 2
- minor compatibility issue HOT 2
- WrongDatabase: Activity database must be ecoinvent_3_8, but set() was also found HOT 4
- Missing EXIOBASE importer, cannot import Exiobase3MonetaryImporter from bw2io HOT 2
- Excel exporter uses the process `activity` when exporting ecoinvent, which breaks everything
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from brightway2-io.