Thank you Larz60+ :)
yield was missing puzzle in my case :P i tried some different ways to do it on my own and i was trying with return instead of yield
yield was missing puzzle in my case :P i tried some different ways to do it on my own and i was trying with return instead of yield
class df_excel: cwd = os.getcwd() def __init__(self, sheetname): self.sheetname = sheetname def excel_to_df(self): cwd = os.getcwd() for file in os.listdir(cwd): if file.endswith('.xlsx'): filename = cwd + '\\' + file self.create_df = pd.read_excel(file, self.sheetname) yield self.create_df def main(): A = df_excel('Prices') for df in A.excel_to_df(): print(df) main()