I need to perform some data analysis on some excel files (that are saved as account numbers of respective customers). I also have a master sheet with all the account numbers in a column. I need to iterate over the "Account Number" column in MasterSheet.xlsx
and read the respective account's excel file (for eg: for account number 123, there is a "123.xlsx", that is located in the same directory as Master Sheet
). Then I need to assign the corresponding account number as their variable name.
For a rough understanding of what I want to do, please refer to the code below. I'd prefer to use pandas
or openpyxl
.
master = pd.read_excel("MasterSheet.xlsx")
for account in master.iterrows():
filename= str(account)+'.xlsx'
account= pd.read_excel(filename)
You can see, I have tried to create a filename from each account number read via for loop. And then assign the account number as the variable name for each account's dataframe.
I know this is a very badly framed question but I tried and couldn't frame it any better. I have just started using python. If you need any further information, please ask.