Skip to content

BUG: Patch for skipping seek() when loading Excel files from urllib3.response.HTTPResponse object #28826

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

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions pandas/io/excel/_base.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import abc
from collections import OrderedDict
from datetime import date, datetime, timedelta
from io import BytesIO
from io import BytesIO, UnsupportedOperation
import os
from textwrap import fill

Expand Down Expand Up @@ -347,7 +347,12 @@ def __init__(self, filepath_or_buffer):
self.book = filepath_or_buffer
elif hasattr(filepath_or_buffer, "read"):
# N.B. xlrd.Book has a read attribute too
filepath_or_buffer.seek(0)
try:
filepath_or_buffer.seek(0)
except UnsupportedOperation:
# HTTPResponse does not support seek()
# GH 28825
pass
self.book = self.load_workbook(filepath_or_buffer)
elif isinstance(filepath_or_buffer, str):
self.book = self.load_workbook(filepath_or_buffer)
Expand Down