From 15cd9d2dedb20a7213b3be34ef54807867071a05 Mon Sep 17 00:00:00 2001 From: Will Ayd Date: Tue, 27 Feb 2018 07:45:17 -0800 Subject: [PATCH 1/2] Added seek to buffer to fix xlwt asv failure --- pandas/io/excel.py | 1 + 1 file changed, 1 insertion(+) diff --git a/pandas/io/excel.py b/pandas/io/excel.py index 0d3d4286f5a3c..0a7fc776673c7 100644 --- a/pandas/io/excel.py +++ b/pandas/io/excel.py @@ -387,6 +387,7 @@ def __init__(self, io, **kwds): self.book = io elif not isinstance(io, xlrd.Book) and hasattr(io, "read"): # N.B. xlrd.Book has a read attribute too + io.seek(0) # GH 19779 data = io.read() self.book = xlrd.open_workbook(file_contents=data) elif isinstance(self._io, compat.string_types): From c14b19e132449b184f31001c4f82cf4f5c4c392f Mon Sep 17 00:00:00 2001 From: Will Ayd Date: Tue, 27 Feb 2018 11:27:00 -0800 Subject: [PATCH 2/2] Added conditional to check for seek on xlrd object --- pandas/io/excel.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pandas/io/excel.py b/pandas/io/excel.py index 0a7fc776673c7..78af86cc00f7f 100644 --- a/pandas/io/excel.py +++ b/pandas/io/excel.py @@ -387,7 +387,10 @@ def __init__(self, io, **kwds): self.book = io elif not isinstance(io, xlrd.Book) and hasattr(io, "read"): # N.B. xlrd.Book has a read attribute too - io.seek(0) # GH 19779 + if hasattr(io, 'seek'): + # GH 19779 + io.seek(0) + data = io.read() self.book = xlrd.open_workbook(file_contents=data) elif isinstance(self._io, compat.string_types):