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

read_excel doesn't accept bytes #20526

Open
2 tasks done
ReRubis opened this issue Jan 2, 2025 · 1 comment
Open
2 tasks done

read_excel doesn't accept bytes #20526

ReRubis opened this issue Jan 2, 2025 · 1 comment
Labels
bug Something isn't working needs triage Awaiting prioritization by a maintainer python Related to Python Polars

Comments

@ReRubis
Copy link

ReRubis commented Jan 2, 2025

Checks

  • I have checked that this issue has not already been reported.
  • I have confirmed this bug exists on the latest version of Polars.

Reproducible example

from pathlib import Path

import polars as pl

bytes_data = Path("Untitled.spreadsheet.xlsx").read_bytes()

try:
    pl.read_excel(bytes_data)
except Exception as e:
    print(e)

Log output

source must be a string or bytes

Issue description

When I try to read a certain xlsx files in bytes, pl.read_excel() fails to read it.
Works on 1.17.

Here is an empty xlsx created in google sheets.
Untitled spreadsheet.xlsx

Expected behavior

A dataframe or a message indicating an empty file.

Installed versions

--------Version info---------
Polars:              1.18.0
Index type:          UInt32
Platform:            Linux-6.12.6-arch1-1-x86_64-with-glibc2.36
Python:              3.11.9 (main, Sep  5 2024, 00:16:19) [GCC 12.2.0]
LTS CPU:             False

----Optional dependencies----
adbc_driver_manager  <not installed>
altair               <not installed>
azure.identity       <not installed>
boto3                <not installed>
cloudpickle          3.1.0
connectorx           <not installed>
deltalake            <not installed>
fastexcel            0.12.0
fsspec               <not installed>
gevent               <not installed>
google.auth          2.37.0
great_tables         <not installed>
matplotlib           3.9.4
nest_asyncio         1.6.0
numpy                1.26.4
openpyxl             3.1.5
pandas               2.2.3
pyarrow              18.1.0
pydantic             2.6.4
pyiceberg            <not installed>
sqlalchemy           2.0.36
torch                <not installed>
xlsx2csv             <not installed>
xlsxwriter           3.2.0
@ReRubis ReRubis added bug Something isn't working needs triage Awaiting prioritization by a maintainer python Related to Python Polars labels Jan 2, 2025
@DoTheBestToGetTheBest
Copy link

you need to wrap your bytes in BytesIO object

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working needs triage Awaiting prioritization by a maintainer python Related to Python Polars
Projects
None yet
Development

No branches or pull requests

2 participants