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

Tags (3)
4 REPLIES
Twelve Stars TRF
Twelve 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
Ten 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