Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
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): Expose top-level "has_header" param for read_excel and read_ods #18078

Merged

Conversation

alexander-beedie
Copy link
Collaborator

@alexander-beedie alexander-beedie commented Aug 7, 2024

Closes #16944 by exposing "has_header" as a generic top-level param that behaves consistently across all supported engines.

Ref: #17727
Ref: #17265

Same param name (and behaviour) as read_csv). Some additional internal cleanups.

Example

Reading from a sheet/table that has no column headers:

import polars as pl

for engine in ("calamine", "openpyxl", "xlsx2csv"):
  df = pl.read_excel(
    source="data.xlsx", 
    has_header=False, 
    engine=engine,
  )
  # shape: (3, 3)
  # ┌──────────┬──────────┬──────────┐
  # │ column_1 ┆ column_2 ┆ column_3 │
  # │ ---      ┆ ---      ┆ ---      │
  # │ i64      ┆ str      ┆ f64      │
  # ╞══════════╪══════════╪══════════╡
  # │ 1        ┆ aaa      ┆ 0.5      │
  # │ 2        ┆ bbb      ┆ 0.0      │
  # │ 3        ┆ ccc      ┆ -1.0     │
  # └──────────┴──────────┴──────────┘

@github-actions github-actions bot added enhancement New feature or an improvement of an existing feature python Related to Python Polars labels Aug 7, 2024
@alexander-beedie alexander-beedie changed the title feat(python): Expose top-level "has_header" param for read_excel (and read_ods) for all engines feat(python): Expose top-level "has_header" param for read_excel and read_ods Aug 7, 2024
@alexander-beedie alexander-beedie added the A-io-excel Area: reading/writing Excel files label Aug 7, 2024
@alexander-beedie alexander-beedie force-pushed the read-excel-has-header branch 3 times, most recently from 9cff502 to 0d36914 Compare August 7, 2024 14:55
Copy link

codecov bot commented Aug 7, 2024

Codecov Report

Attention: Patch coverage is 72.88136% with 16 lines in your changes missing coverage. Please review.

Project coverage is 80.34%. Comparing base (3dda47e) to head (0d36914).

Files Patch % Lines
py-polars/polars/io/spreadsheet/functions.py 72.88% 10 Missing and 6 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #18078      +/-   ##
==========================================
- Coverage   80.37%   80.34%   -0.03%     
==========================================
  Files        1496     1496              
  Lines      197542   197567      +25     
  Branches     2820     2829       +9     
==========================================
- Hits       158771   158744      -27     
- Misses      38249    38296      +47     
- Partials      522      527       +5     

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

@ritchie46
Copy link
Member

A rebase away...

@alexander-beedie
Copy link
Collaborator Author

alexander-beedie commented Aug 13, 2024

A rebase away...

Great, thanks - missed this earlier; rebased :))

@alexander-beedie alexander-beedie merged commit b585293 into pola-rs:main Aug 13, 2024
14 checks passed
@alexander-beedie alexander-beedie deleted the read-excel-has-header branch August 13, 2024 18:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-io-excel Area: reading/writing Excel 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.

"has_header" in "read_options" for read_excel has inconsistent behavior across engines
2 participants