Python Forum
all_data.append not work it should be
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
all_data.append not work it should be
#1
Huh ** I am not programmer Big Grin

currently I am trying to use "all_data.append" to append all xlsx files into one file ,
it return result but returned result is not complete, i cant identify where are the errors.
errors sported
1)returned result not complete Doh
2) why i cant label the path G? Wall
code as below;
master1 = Tk()
P = str()
G = str()


Label(master1, text="Folder Location :",width=20).grid(row=0)


def OpenFile2():

        master1.filename = filedialog.askdirectory()
        G = os.path.normpath(master1.filename)
        P = os.path.isdir(G)#check 
        print("\n", P,"\n", G) #check 
Button(master1, text ="OpenFile2", command = OpenFile2,width=10).grid(column = 3,row=0)       
Label(master1, text=G,width=60).grid(row=0,column=2)
        
all_data = pd.DataFrame()     
for f in glob.glob(G + "\*.xlsx"):
print("\n", P,"\n", G) #check 
        df = pd.read_excel(f)
        all_data = all_data.append(df,ignore_index=True)
print (all_data) #test print
        writer = ExcelWriter('Pandas-Example.xlsx')
ll_data.to_excel(writer,'Sheet1',index=False)
        writer.save()   


master1.mainloop()
Reply
#2
as is now, your code cannot run, because the indentation is broken. please, fix the indentation
Reply
#3
(Nov-29-2017, 11:17 AM)buran Wrote: as is now, your code cannot run, because the indentation is broken. please, fix the indentation
what do u mean indentation here? Huh
Reply
#4
please, read https://python-forum.io/Thread-Basic-Indentation
Reply
#5
see: https://www.python.org/dev/peps/pep-0008/#indentation
Reply


Forum Jump:

User Panel Messages

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