IAMconsortium / pyam

Analysis & visualization of energy & climate scenarios
https://pyam-iamc.readthedocs.io/
Apache License 2.0
226 stars 118 forks source link

Better error message when initializing with invisible columns #634

Closed danielhuppmann closed 2 years ago

danielhuppmann commented 2 years ago

Please confirm that this PR has done the following:

Description of PR

Per a user support request for the Scenario Explorer upload, we noticed that an xlsx file which has an "invisible" column (e.g., a whitespace in a column to the right of the data) raises a generic

ValueError: IamDataFrame constructor not properly called!

This is not really helpful to users.

This PR restructures the try-except such that a user will receive a more intelligible error message including the column name:

ValueError: Empty cells in `data` (columns: 'unnamed: 7'):
...
codecov[bot] commented 2 years ago

Codecov Report

Merging #634 (d5e95e1) into main (38897ff) will increase coverage by 0.0%. The diff coverage is 95.4%.

Impacted file tree graph

@@          Coverage Diff          @@
##            main    #634   +/-   ##
=====================================
  Coverage   94.6%   94.6%           
=====================================
  Files         57      57           
  Lines       5651    5658    +7     
=====================================
+ Hits        5347    5355    +8     
+ Misses       304     303    -1     
Impacted Files Coverage Δ
pyam/utils.py 91.2% <85.7%> (+0.4%) :arrow_up:
pyam/core.py 94.9% <100.0%> (-0.1%) :arrow_down:
tests/test_io.py 100.0% <100.0%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 38897ff...d5e95e1. Read the comment docs.

phackstock commented 2 years ago

Since this is a draft PR, should I review this or is it not ready yet?