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): Add an "include_file_paths" parameter to read_excel and read_ods #20476

Merged
merged 1 commit into from
Dec 27, 2024

Conversation

alexander-beedie
Copy link
Collaborator

@alexander-beedie alexander-beedie commented Dec 27, 2024

Closes #20447.

Adds an "include_file_paths" parameter to the spreadsheet reading functions, with the same signature and behaviour as we have elsewhere (the param takes the column name into which the path will be written, appends it as a new column to the end, and reads from BytesIO sources are tagged with the synthetic path "in-mem").

Examples

pl.read_excel("~/data.xlsx", sheet_id="test", include_file_paths="wbook")

# shape: (2, 3)
# ┌──────────┬──────────┬────────────────────────┐
# │ Header 1 ┆ Header 2 ┆ wbook                  │
# │ ---      ┆ ---      ┆ ---                    │
# │ str      ┆ str      ┆ str                    │
# ╞══════════╪══════════╪════════════════════════╡
# │ a        ┆ b        ┆ /Users/elvis/data.xlsx │
# │ a        ┆ b        ┆ /Users/elvis/data.xlsx │
# └──────────┴──────────┴────────────────────────┘

@github-actions github-actions bot added enhancement New feature or an improvement of an existing feature python Related to Python Polars labels Dec 27, 2024
@alexander-beedie alexander-beedie added the A-io-spreadsheet Area: reading/writing Excel/ODS files label Dec 27, 2024
Copy link

codecov bot commented Dec 27, 2024

Codecov Report

Attention: Patch coverage is 70.00000% with 3 lines in your changes missing coverage. Please review.

Project coverage is 78.98%. Comparing base (8b3afb7) to head (9f67f7f).
Report is 3 commits behind head on main.

Files with missing lines Patch % Lines
py-polars/polars/io/spreadsheet/functions.py 70.00% 2 Missing and 1 partial ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main   #20476   +/-   ##
=======================================
  Coverage   78.98%   78.98%           
=======================================
  Files        1563     1563           
  Lines      220562   220576   +14     
  Branches     2490     2492    +2     
=======================================
+ Hits       174206   174218   +12     
- Misses      45783    45785    +2     
  Partials      573      573           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@ritchie46 ritchie46 merged commit 6a7adce into pola-rs:main Dec 27, 2024
21 checks passed
@alexander-beedie alexander-beedie deleted the include-workbook-file-path branch December 27, 2024 17:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-io-spreadsheet Area: reading/writing Excel/ODS files 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.

Add "include_file_paths" argument to read_excel
2 participants