GET the last file from Remote directory ftp

Highlighted
Five Stars

GET the last file from Remote directory ftp

 

Hello Community ,

 

I need help plaiiiise

 

I wanna get all the recent file from a remote directory FTP  to my local ,then delete this file from local after appload them to my Mysql Database:

 

the remote directory contain a CSV file withe the name like 20170515_Contact.csv       (2017:year,05 month, 15 day)

every day there is the new files.

 

i wanna just get the file of the recent day.

 

this is my job : tftpconnection-->tftlistfile-->tftpget--tfileinputDelimeted-->tlogrow-->tmap--->mysqloutput

 

 

help me to configure all this component in order to get just the recent file  to my local directory then delete them after having all the date at mysql

thank youuuuuuuuuuuuuuu

Forteen Stars TRF
Forteen Stars

Re: GET the last file from Remote directory ftp

Try this:

tFTPConnection-->tFTPGet--tFileInputDelimited-->tLogTow-->tMap--->tMysqlOutput (no tFTPFileList component).

To get the file for the current day from your FTP server, add a filemask with the following syntax:

TalendDate.formatDate("yyyyMMddHH",TalendDate.getCurrentDate()) + "_Contact.csv"

The component should look like this:

Capture.PNG

If necessary, define the local directory according to the place where you want to get the file with the tFileInputDelimited.


TRF
Thirteen Stars

Re: GET the last file from Remote directory ftp

This is not really most resent file, as example most resent mean - You have 3 backup from same day, but need take latest

 

but Your tasks could be achieved with simple name patterns:

For yesterday:

TalendDate.formatDate("yyyyMMdd",TalendDate.addDate(TalendDate.getCurrentDate() ,-1,"dd")) +"*.csv"
or
TalendDate.formatDate("yyyyMMdd",TalendDate.addDate(TalendDate.getCurrentDate() ,-1,"dd")) +"_Contact.csv"

For today:

TalendDate.formatDate("yyyyMMdd",TalendDate.getCurrentDate()) +"*.csv"
or
TalendDate.formatDate("yyyyMMdd",TalendDate.getCurrentDate()) +"_Contact.csv"

 

use this pattern for tFTPFileList

-----------
Five Stars

Re: GET the last file from Remote directory ftp

Thank you very much

Five Stars

Re: GET the last file from Remote directory ftp

Thank you
Forteen Stars TRF
Forteen Stars

Re: GET the last file from Remote directory ftp

@informatiste thank's to mark your case as solved (Kudos also accepted)


TRF
Six Stars

Re: GET the last file from Remote directory ftp

@vapukov, I used the same for my job that has to fetch files from ftp server. The job works but doesn't get any files on to local directory despite them being on ftp. The date format on ftp is dd/MM/yyyy HH:mm:ss. Could that be the reason?

Four Stars

Re: GET the last file from Remote directory ftp

down vote The answer is that you probably can't do this using just wget or any other single tool that I am aware of. What you probably need to do is write a script that will use wget/curl/whatever that will request a directory listing from the ftp server. Then the script will select and retrieve the right file based on the file's name, or some other criteria Clean Master Facebook Lite  Mathway