I am using this code to get last xlsx file from ftp.
import pandas as pd
import ftplib
ftp = ftplib.FTP('ftpname.com', 'client','mdp')
ftp.retrlines('LIST')
ftp.cwd("/DATA")
names = ftp.nlst()
latest_time = None
latest_name = None
for name in names:
time = ftp.sendcmd("MDTM " + name)
if (latest_time is None) or (time > latest_time):
latest_name = name
latest_time = time
print(latest_name)
for the moment I can only get the file name as string, but I couldn't read it as a dataframe or to upload the xlsx file from the server to the local machine.