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

HRA criteria table parsing throws cryptic error when section header is missing #1191

Closed
phargogh opened this issue Feb 19, 2023 · 0 comments · Fixed by #1192
Closed

HRA criteria table parsing throws cryptic error when section header is missing #1191

phargogh opened this issue Feb 19, 2023 · 0 comments · Fixed by #1192
Assignees
Labels
bug Something isn't working in progress This issue is actively being worked on

Comments

@phargogh
Copy link
Member

Looking at a user's forums post, the following exception was being raised:

>>> hra._parse_criteria_table('/Users/jdouglass/Downloads/2023-02-18-manipreyamrakash-hra-criteria-table/criteria_score.csv', 'target.csv')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/jdouglass/workspace/phargogh/invest/src/natcap/invest/hra.py", line 1781, in _parse_criteria_table
    attribute_name = table[current_stressor_header_row][col_index]
UnboundLocalError: local variable 'current_stressor_header_row' referenced before assignment

The problem is that the user's criteria table has the field "HABITAT RESILIENCE ATIRIBUTES " instead of "HABITAT RESILIENCE ATTRIBUTES". The typo is causing the program to break in a cryptic way.

@phargogh phargogh added bug Something isn't working in progress This issue is actively being worked on labels Feb 19, 2023
@phargogh phargogh self-assigned this Feb 19, 2023
phargogh added a commit to phargogh/invest that referenced this issue Feb 19, 2023
Now, the criteria table parsing will trim leading/trailing whitespace
from string table cells and will also raise an exception if one or more
of the required table sections is missing.

RE:natcap#1191
phargogh added a commit to phargogh/invest that referenced this issue Feb 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working in progress This issue is actively being worked on
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant