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

use_columns silently skips empty columns at the beginning #303

Open
jsarbach opened this issue Oct 15, 2024 · 2 comments
Open

use_columns silently skips empty columns at the beginning #303

jsarbach opened this issue Oct 15, 2024 · 2 comments
Labels

Comments

@jsarbach
Copy link

Given the following spreadsheet with an empty first column:
image

Loading the sheet with e.g. use_columns='B:C' (or use_columns=[1, 2]) actually selects columns C and D:

read_excel('sheet.xlsx').load_sheet(0, use_columns='B:C').to_polars()
shape: (3, 2)
┌────────┬───────┐
│ SecondThird │
│ ------   │
│ f64f64   │
╞════════╪═══════╡
│ 4.07.0   │
│ 5.08.0   │
│ 6.09.0   │
└────────┴───────┘

And raises ColumnNotFoundError with use_columns='B:D' or use_columns=[1, 2, 3]:

read_excel('sheet.xlsx').load_sheet(0, use_columns='B:D').to_polars()
_fastexcel.ColumnNotFoundError: column at index 3 not found
Context:
    0: available columns are: [ColumnInfo { name: "First", index: 0, dtype: Float, column_name_from: LookedUp, dtype_from: Guessed }, ColumnInfo { name: "Second", index: 1, dtype: Float, column_name_from: LookedUp, dtype_from: Guessed }, ColumnInfo { name: "Third", index: 2, dtype: Float, column_name_from: LookedUp, dtype_from: Guessed }]
@PrettyWood
Copy link
Member

Yes the engine behind fastexcel calamine skips empty columns by default.
I plan to add an option on calamine directly like I did for skipping empty rows

@alexander-beedie
Copy link
Contributor

Yes the engine behind fastexcel calamine skips empty columns by default. I plan to add an option on calamine directly like I did for skipping empty rows

@PrettyWood: If you add it anytime soon I'll hook into it from Polars, as we have a similar request on our side now, and I'm adding a drop_empty_cols param to influence this behaviour (where the underlying engine has support) :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants