Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
building class
#3
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

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()
Reply


Messages In This Thread
building class - by zarize - Mar-06-2020, 04:06 PM
RE: building class - by Larz60+ - Mar-07-2020, 12:09 AM
RE: building class - by zarize - Mar-09-2020, 09:09 AM
RE: building class - by Larz60+ - Mar-09-2020, 07:21 PM
RE: building class - by zarize - Mar-10-2020, 08:11 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Building a class for polygons and triangles in 2-space crosshairpvp 0 1,604 Nov-22-2019, 02:04 AM
Last Post: crosshairpvp
  Building a class for sqlite3 interaction Nuzvee 5 3,380 Jan-29-2019, 06:47 AM
Last Post: Nuzvee

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020