from ftplib import FTP import socket ftp = FTP('***.*.***.***') ftp.login(user='someusername',passwd='somepassword') ftp.cwd('fcst') // this is a subfolder on the ftp.No error here i=4 filename='C:\Users\user\Desktop\INTERNSHIP\SOLAR_DADRI\data.xlsx' localfile=open(filename,'wb') while(i<7): j=1 while(j<10): fileName='dadfrcst0'+str(j)+'0'+str(i)+'r2.xlsx' j=j+1 ftp.retrbinary('RETR '+fileName,localfile.write,1024) i=i+1 ftp.close() localfile.close() So i was trying to retrieve files from a FTP server and write them all down into one excel file. I want to essentially append as all the files have the same format and i want to do a timeseries analysis.
Also just so you know all the files on the server are in excel format are files in different dates as specified by the regular expression i used to retrieve..i.e 'dadrfcst0104r2.xlsx' implies 1st April's data.
So when i run the code it shows the file size to be big and when i open it it shows an error and then is showing only the 1st april data.. The loops are right. There is no error there. PLEASE HELP.
xlsxfiles like this.