Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
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
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.
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.