Skip to content

HOTFIX - t&d download links#17

Merged
dt-woods merged 3 commits intoKeyLogicLCA:developmentfrom
frankhanna94:development
Nov 25, 2025
Merged

HOTFIX - t&d download links#17
dt-woods merged 3 commits intoKeyLogicLCA:developmentfrom
frankhanna94:development

Conversation

@frankhanna94
Copy link

No description provided.

# bugfix: url for year 2024 [FH]
url_c = (
"https://www.eia.gov/electricity/state/"
+ "/xls/"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Copy link
Author

@frankhanna94 frankhanna94 Nov 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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]

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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"

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

True - i updated the code directly on github (w/o testing)

Copy link

@dt-woods dt-woods left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All good.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See line comments for a new URL creation framework.

@dt-woods dt-woods merged commit 930c11d into KeyLogicLCA:development Nov 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants