I have several Excel files that I would like to read in with my code. Instead of using the following command with the explicit file name:
df = read_excel("a.xlsx",sheet_name=0)
I would like to list all of my Excel file names in a .txt file (like data.txt) and then read data.txt line by line to store each Excel file name in a variable: i.e. after reading the first line of data.txt which is a.xlsx, I will assign
var1 = a.xlsx
My question is how do I open a.xlsx afterwards.
df = read_excel(var1,sheet_name=0)
does not work. Is there a way to open Excel files without having their names explicitly written out in Python? Thanks in advance.
pandas?var1 = a.xlsxis not valid python unlessa.xlsxexists. That's probably not what you want. You wantvar1 = 'a.xlsx'.does not work? What error do you get?