IndEcol / RECC-ODYM

The RECC model
MIT License
21 stars 10 forks source link

IndexError: ParseModelControl, problem with reading xlsx files into python #57

Open SchuirF opened 11 months ago

SchuirF commented 11 months ago

Hello there,

I am trying to apply the ODYM RECC model, but I get a 'list index out of range' error for ParseModelControl in RECC_G7IC_V2_2.py when I run the code. It is probably due to reading the .xlsx files into Python, which I already found out in issue #16 from IndEcol/ODYM. However, I have not yet been able to derive an individual solution to my problem, unfortunately. I don't know what needs to be changed or updated for this and didn't want to change anything in the code.

I want to use ODYM-RECC for a research project and would be very grateful for your help. Many thanks in advance!

Screenshot 2023-07-25 IndexError ParseControl

CarrerF commented 11 months ago

Hi,

I would first check if the Config Sheet is set correctly. Is the D4 cell in the cover of RECC_Config.xlsx containing the proper name of the sheet with your settings?

SchuirF commented 9 months ago

Thank you for your answer! Unfortunately, I have not been active on the project for a long time now, but I believe that my Config Sheet is set correctly. I think the problem lies more in reading in the format (.xlsx). Screenshot 2023-10-20 110457

CarrerF commented 9 months ago

Hi @SchuirF, it seems that you are using an old version of the model. A few years ago, the package xlrd stopped supporting .xlsx fil, focusing on the old Excel formal .xls only. The code has been entirely rewritten using the library openpyxl.

If you would prefer keeping the commit of the code you already have, you might have to install a version of xlrd prior to 2.0.0.

SchuirF commented 8 months ago

Hi @CarrerF , All right, I had already suspected that. But I didn't know that the code had already been rewritten. I will have a look if I find the new version and try again!

I had tried to install the older version xlrd==1.2.0 before, but then I got this error instead:

AttributeError: 'ElementTree' object has no attribute 'getiterator'

The problem was probably that you need xlrd==1.2.0 to open xlsx files. But this version seems to have security vulnerabilities and also does not have the attribute getiterator, which generates exactly this error.

Thank you so much!

CarrerF commented 8 months ago

Hi @SchuirF ,

I remember having the same AttributeError. For me, adding the line xlrd.xlsx.Element_has_iter = True after importing the xlrd package worked.

You can find the new code in ODYM_RECC_Main.py on the front page of this repository. However, the RECC model relies on the ODYM package (https://github.com/IndEcol/ODYM), which has been updated too. You would need to update it as well. The dataset has also been extended and reviewed, so I suspect that the version of the dataset you have will not be compatible with the newest code. Please, contact @stefanpauliuk (the owner of the repository) to get access to the dataset.

SchuirF commented 8 months ago

Hello @CarrerF, when I add line xlrd.xlsx.Element_has_iter = True , I get this error:

Screenshot 2023-11-03 115632 It seems there is something fishy about it. Thanks for the help anyway, but maybe I'd better concentrate on the newer model version now. I will get in touch with @stefanpauliuk.

Thanks for your help!