Skip to content

ENH Pass kwds from ExcelFile ctr to xlrd.open_workbook. For example, thi... #4439

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 2 commits into from
Closed
Changes from 1 commit
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
4 changes: 2 additions & 2 deletions pandas/io/excel.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,10 @@ def __init__(self, path_or_buf, kind=None, **kwds):
self.tmpfile = None

if isinstance(path_or_buf, compat.string_types):
self.book = xlrd.open_workbook(path_or_buf)
self.book = xlrd.open_workbook(path_or_buf, **kwds)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should these be named kwds? or can open_workbook deal with any?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

xlrd.open_workbook accepts a number of parameters: http://www.lexicon.net/sjmachin/xlrd.html#xlrd.open_workbook-function

That being said I saw the kwd argument in the ExcelFile constructor. Currently that kwd is not used which means if the user tries to pass any additional parameters, or misspells them, they are silently dropped.

This change not only allows passing more arguments down to xlrd but also adds an additional runtime check.

else:
data = path_or_buf.read()
self.book = xlrd.open_workbook(file_contents=data)
self.book = xlrd.open_workbook(file_contents=data, **kwds)

def parse(self, sheetname, header=0, skiprows=None, skip_footer=0,
index_col=None, parse_cols=None, parse_dates=False,
Expand Down