I can't test the following as I don't have a bunch of xlsx files lying around
if you get errors that you can't figure out, post them
if you get errors that you can't figure out, post them
from pathlib import Path import os class df_excel: def __init__(self, sheetname): # set starting path (src code repository) os.chdir(os.path.abspath(os.path.dirname(__file__))) homepath = Path('.') self.filelist = [filename for filename in homepath.iterdir() \ if filename.is_file() and filename.suffix == '.xlsx'] self.sheetname = sheetname def excel_to_df(self): for file in self.filelist: self.create_df = pd.read_excel(file, self.sheetname) yield self.create_df def main(): A = df_excel(r'Database_sheet') for df in A.excel_to_df() print(df) if __name__ == '__main__': main()