Skip to main content
Announcements
See what Drew Clarke has to say about the Qlik Talend Cloud launch! READ THE BLOG
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Need to read last seven days files from a directory

Hi Team,

I need help in reading last seven days file from a directory. I am new to Talend and not much comfortable with Java. So any suggestions would be very helpful here. 

Thanks

Labels (4)
2 Replies
Anonymous
Not applicable
Author

Try this:

tFileList (order by modified date desc) -- iterate --> tFileProperties -- row1 --> tMap (here filter the files by mtime) -- out --> tFileCopy

Unfortunately it is a bit cumbersome to filter. First of all, keep in mind the date is actually hold as number of milliseconds since 1970-01-01.

You can use following code in an tMap expression editor to convert the mtime into a Date and filter: 

row1.mtime > TalendDate.addDate(TalendDate.getCurrentDate(), -7, "dd").getTime()

The idea is to compare the modified datetime (mtime) from the file with the datetime of the current date minus 7 days.

The expression above returns a boolean and you can use it in the filter section of an output flow of the tMap.

Anonymous
Not applicable
Author

Try this:

tFileList (order by modified date desc) -- iterate --> tFileProperties -- row1 --> tMap (here filter the files by mtime) -- out --> tFileCopy

Unfortunately it is a bit cumbersome to filter. First of all, keep in mind the date is actually hold as number of milliseconds since 1970-01-01.

You can use following code in an tMap expression editor to convert the mtime into a Date and filter: 

row1.mtime > TalendDate.addDate(TalendDate.getCurrentDate(), -7, "dd").getTime()

The idea is to compare the modified datetime (mtime) from the file with the datetime of the current date minus 7 days.

The expression above returns a boolean and you can use it in the filter section of an output flow of the tMap.