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

feat(python): allow read_excel to load from remote http locations #13753

Merged
merged 1 commit into from
Jan 15, 2024

Conversation

alexander-beedie
Copy link
Collaborator

@alexander-beedie alexander-beedie commented Jan 15, 2024

Closes #13718.

Small (three line 😅) update to run the path passed to read_excel through the same utility function as read_csv (for paths that begin with the "http" prefix).

import polars as pl

remote_file = "https://atb-archive.nrel.gov/electricity/2020/files/2020-ATB-Data.xlsm"
pl.read_excel(remote_file, sheet_name="LCOE Range")

# shape: (12, 4)
# ┌──────────────────────────────┬───────────┬────────────┬────────────┐
# │ Technology                   ┆ Min       ┆ Difference ┆ Max        │
# │ ---                          ┆ ---       ┆ ---        ┆ ---        │
# │ str                          ┆ f64       ┆ f64        ┆ f64        │
# ╞══════════════════════════════╪═══════════╪════════════╪════════════╡
# │ Natural Gas                  ┆ 29.694559 ┆ 66.110439  ┆ 95.804998  │
# │ Coal                         ┆ 72.223685 ┆ 93.83216   ┆ 166.055844 │
# │ Nuclear                      ┆ 75.832182 ┆ 2.0        ┆ 75.832182  │
# │ Land-Based Wind              ┆ 28.320708 ┆ 98.920068  ┆ 127.240776 │
# │ Offshore Wind                ┆ 84.418738 ┆ 87.135401  ┆ 171.554139 │
# │ …                            ┆ …         ┆ …          ┆ …          │
# │ Solar - PV Dist. Residential ┆ 88.112836 ┆ 48.651903  ┆ 136.764739 │
# │ Solar - CSP                  ┆ 88.836103 ┆ 22.502418  ┆ 111.33852  │
# │ Geothermal                   ┆ 58.400147 ┆ 366.001221 ┆ 424.401367 │
# │ Hydropower                   ┆ 49.315104 ┆ 46.505838  ┆ 95.820942  │
# │ Biopower                     ┆ 86.066784 ┆ 29.196242  ┆ 115.263026 │
# └──────────────────────────────┴───────────┴────────────┴────────────┘

@github-actions github-actions bot added enhancement New feature or an improvement of an existing feature python Related to Python Polars labels Jan 15, 2024
Copy link
Contributor

@stinodego stinodego left a comment

Choose a reason for hiding this comment

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

The walrus here hurts my brain but looks like this would work 👍

@alexander-beedie
Copy link
Collaborator Author

alexander-beedie commented Jan 15, 2024

The walrus here hurts my brain but looks like this would work 👍

At least I didn't write a module to Walrus All The Things™ (@MarcoGorelli, you mad scientist 😂)

@alexander-beedie alexander-beedie merged commit 2f15e03 into pola-rs:main Jan 15, 2024
13 checks passed
@alexander-beedie alexander-beedie deleted the excel-over-http branch January 15, 2024 21:03
r-brink pushed a commit to r-brink/polars that referenced this pull request Jan 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or an improvement of an existing feature python Related to Python Polars
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Read a remote excel file with read_excel
2 participants