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

Issue when importing CSV inventories #131

Closed
romainsacchi opened this issue May 26, 2022 · 1 comment
Closed

Issue when importing CSV inventories #131

romainsacchi opened this issue May 26, 2022 · 1 comment

Comments

@romainsacchi
Copy link

The import of CSV inventory files using bw2io.CSVImporter() fails.

For example, using the CSV located at : https://raw.githubusercontent.com/brightway-lca/brightway2-io/master/bw2io/data/examples/example.csv

fp = "lci-example.csv"
i = bw2io.CSVImporter(fp)

throws the following error:

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
Input In [3], in <cell line: 2>()
      1 fp = "lci-example.csv"
----> 2 i = bw2io.CSVImporter(fp)

File ~/GitHub/brightway2-io/bw2io/importers/excel.py:109, in ExcelImporter.__init__(self, filepath)
    105 start = time()
    106 data = self.extractor.extract(filepath)
--> 109 data = [(x, y) for x, y in data if valid_first_cell(x, y)]
    110 print(
    111     "Extracted {} worksheets in {:.2f} seconds".format(
    112         len(data), time() - start
    113     )
    114 )
    115 if data and any(line for line in data):

File ~/GitHub/brightway2-io/bw2io/importers/excel.py:109, in <listcomp>(.0)
    105 start = time()
    106 data = self.extractor.extract(filepath)
--> 109 data = [(x, y) for x, y in data if valid_first_cell(x, y)]
    110 print(
    111     "Extracted {} worksheets in {:.2f} seconds".format(
    112         len(data), time() - start
    113     )
    114 )
    115 if data and any(line for line in data):

ValueError: too many values to unpack (expected 2)

It seems it is expecting to receive items of length of 2 when iterating over data, but items in data have a length superior to 2.

@romainsacchi romainsacchi changed the title Issue when import CSV inventories Issue when importing CSV inventories May 26, 2022
@cmutel
Copy link
Member

cmutel commented Jun 2, 2022

Fixed in 62669e3

@cmutel cmutel closed this as completed Jun 2, 2022
tngTUDOR added a commit that referenced this issue Oct 22, 2022
Add fix to import CSV inventories implemented in master.
The excel submodule of the importers module was isorted.
cmutel pushed a commit that referenced this issue May 17, 2023
Add fix to import CSV inventories implemented in master.
The excel submodule of the importers module was isorted.
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

2 participants