Pandas: Looking up the list of sheets in an excel file

The new version of Pandas uses the following interface to load Excel files:

    read_excel('path_to_file.xls', 'Sheet1', index_col=None, na_values=['NA'])

but what if I don't know the sheets that are available?

For example, I am working with excel files that the following sheets

Data 1, Data 2 ..., Data N, foo, bar

but I don't know N a priori.

Is there any way to get the list of sheets from an excel document in Pandas?

You can still use the ExcelFile class (and the sheet_names attribute):

    xl = pd.ExcelFile('foo.xls')

    xl.sheet_names  # see all sheet names

    xl.parse(sheet_name)  # read a specific sheet to DataFrame

seedocs for parse for more options...


Back to homepage or read more recommendations: