Search code examples
pythonbrightway

Brightway2: Problems importing ecoinvent 3.6 (ecospold files)


I want to import ecoinvent 3.6 is a database in my brightway2 project. I have downloaded the required ecospold data files from Ecoinvent, however I get the following error:

fpei36 = r"C:~\ecoinvent_36_cut-off_lci_ecoSpold02.7z" # name of path 
ei36 = bw.SingleOutputEcospold2Importer(fpei36, 'ecoinvent 3.6 cutoff')

Traceback (most recent call last):

File "", line 1, in ei36 = bw.SingleOutputEcospold2Importer(fpei36, 'ecoinvent 3.6 cutoff')

File "~\Anaconda\lib\site-packages\bw2io\importers\ecospold2.py", line 67, in init self.data = extractor.extract(dirpath, db_name, use_mp=use_mp)

File "~\Anaconda\lib\site-packages\bw2io\extractors\ecospold2.py", line 93, in extract data = [p.get() for p in results]

File "~\Anaconda\lib\site-packages\bw2io\extractors\ecospold2.py", line 93, in data = [p.get() for p in results]

File "~\Anaconda\lib\multiprocessing\pool.py", line 657, in get raise self._value

UnicodeDecodeError: 'utf-8' codec can't decode byte 0xbc in position 2: invalid start byte

I would not know 1) what is wrong and b) how I can fix what is going wrong.

Thanks for your help!


Solution

  • You are passing the path to a zip (.7z) file. The dirpath argument should instead be the path to a directory with the files contained in the zip file.

    To get going, simply unzip the file first, and then change your code to fpei36 = r"C:~\path_to_dir_with_thousands_of_ecospold_files"

    You can unzip the file in Python, see here for example. You can also simply unzip it using a tool such as this before you get coding.