Quantcast
Channel: Active questions tagged excel - Stack Overflow
Viewing all articles
Browse latest Browse all 90209

iterating over each cell in account number column and using that to read a excel file

$
0
0

I need to perform some data analysis on some excel files (that are saved as account number of respective customesr). I also have a master sheet with all the account numbers in a column. I need python to iterate over "Account Number" column in "MasterSheet.xlsx" and read the respective account's excel file (for eg: for account number 123, i have a "123.xlsx", that is in the same location as Master Sheet) and then assign that account number as their variable name. For a rough understanding of what i want to do, please refer the below code.I want 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 better. I have just started using python. Please help. I am stuck here. If you need any further information, ask. But please help.


Viewing all articles
Browse latest Browse all 90209

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>