I have excel files with many tabs. I want to concat all of them, one tab at a time.
I am doing:
mypath = "mypath"
files = os.listdir(mypath)
files = [os.path.join(mypath,f) for f in files if f[-4:]=='xlsx']
sheets = pandas.ExcelFile(files[0]).sheet_names
Now, say my tabs are alpha, beta, gamma, etc., I want to create a liust of dataframes df_alpha, df_beta, etc. that are the union of all the alpha tabs of the files in. my directory.
By doing:
for sheet in sheets:
df = pandas.DataFrame()
for f in files:
df = pandas.concat([df, pandas.read_excel(f, sheet_name=sheet)])
I can get what I want, but of course I only have a dataframe which is the union of the last tab in each file. How can I change the code so that I have a list of dfs, each named df_alpha, df_beta, etc.?