1

Let's say that I have something like the following:

target = "path_to_excel.xlsx"
raw_data = pandas.ExcelFile(target)

Then if I use the method:

raw_data.sheet_names

I will get a list of the sheet names contained within that spreadsheet. My question is how would I create a variable number of data frames based upon the number of sheets? IE:

In [1] len(raw_data.sheet_names)
Out [1] 3

list_of_df_names = []
for x in range(len(raw_data.sheet_names)):
    list_of_df_names.append("df"+str(x))

for i, element in enumerate(list_of_df_names):
    element = pandas.read_excel(raw_data, raw_data.sheet.names[i])
Alexander
  • 105,104
  • 32
  • 201
  • 196
  • 2
    why not just create a dict of dfs, so the key is the sheet name and the value are the dfs? – EdChum Mar 18 '16 at 22:26

0 Answers0