HOTFIX - t&d download links#17
Conversation
| # bugfix: url for year 2024 [FH] | ||
| url_c = ( | ||
| "https://www.eia.gov/electricity/state/" | ||
| + "/xls/" |
There was a problem hiding this comment.
When I test this, I get the following URL:
https://www.eia.gov/electricity/state//xls/SEP Tables for AL.xlsx, which appears to have a double-forward slash between 'state' and 'xls'. Is the state name supposed to be here?
There was a problem hiding this comment.
sorry about the typo - there is an extra '/' after state.
the state name shouldn't appear in the final link.
correct link format: https://www.eia.gov/electricity/state/xls/SEP Tables for AL.xlsx
I changed it.
| # bugfix: url for year 2023 [FH] | ||
| # this has to be updated later when 2023 data gets archived | ||
| # and links should be rechecked for compatibility with 2024 data (when released) | ||
| # bugfix: url for year 2024 [FH] |
There was a problem hiding this comment.
The original intention of url_b was to capture the most-recent version of state-level workbooks. It seems to me that url_b is no longer a valid URL with url_c serving as the new current URL. I suggest removing url_b, then it is a simplified case of creating a URL framework:
url_key = key.replace(" ", "")
url = f"https://www.eia.gov/electricity/state/archive/{year}/{url_key}/xls/"
if int(year) > 2023:
url = url.replace(f"/archive/{year}/{url_key}/", "/")
url += "SEP%20Tables%20for%20" + f"{STATE_ABBREV[key].upper()}.xlsx"
elif int(year) == 2023:
url += "SEP%20Tables%20for%20" + f"{STATE_ABBREV[key].upper()}.xlsx"
else:
url += f"{STATE_ABBREV[key]}.xlsx"There was a problem hiding this comment.
True - i updated the code directly on github (w/o testing)
There was a problem hiding this comment.
See line comments for a new URL creation framework.
No description provided.