Giter Site home page Giter Site logo

Comments (5)

cmutel avatar cmutel commented on July 29, 2024

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.

danielPclos avatar danielPclos commented on July 29, 2024

Dear Christopher,

Thank you so much for your quick response.
Your solution works fine! 🙂

Kind regards,
Daniel

from brightway2-io.

danielPclos avatar danielPclos commented on July 29, 2024

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.

cmutel avatar cmutel commented on July 29, 2024

@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.

danielPclos avatar danielPclos commented on July 29, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.