From 892dd3d29e3c9dbf24963d70b2b6dad74bed93d2 Mon Sep 17 00:00:00 2001 From: William Ayd Date: Tue, 27 Feb 2018 13:28:22 -0800 Subject: [PATCH] ASV: Added seek to buffer to fix xlwt asv failure (#19926) * Added seek to buffer to fix xlwt asv failure * Added conditional to check for seek on xlrd object --- pandas/io/excel.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pandas/io/excel.py b/pandas/io/excel.py index 0d3d4286f5a3c..78af86cc00f7f 100644 --- a/pandas/io/excel.py +++ b/pandas/io/excel.py @@ -387,6 +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 + 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):