Friday 4 April 2014

Talend - How to get Last Modified File from a directory using tFileList


Talend - How to get Last Modified File from a directory using tFileList


We often have need to get last modified file from a list of files in a directory. We can use tFileList component to give us list of files sorted (DESC/ASC) from a directory, but for now it does not have feature to restrict to last modified file. 
one possible solution to achieve this is as below

tFileList(sorted DESC by file modified date) ------> tFixedFlowInput (schema - filename, filenumber) ----->tHashOutput

here in tFixedFlowInput filename = file(String)globalMap.get("tFileList_1_CURRENT_FILEPATH")+"/"+(String)globalMap.get("tFileList_1_CURRENT_FILE")

filenumber = (Integer)globalMap.get("tFileList_1_NB_FILE")

What above will accomplish is get list of all files in the directory with their number/rank - where the file last modified will have file number =1 and next to that will have 2...and so on.

Now on SubJobOK of above tFileList you can have tHashInput which will read from above tHashOutput and filter only row where filenumber==1 - which means the last modified file.

tHashInput (link to tHashoutput) ---->tFilterRow(filenumber==1)------>tLogRow






7 comments:

  1. how to get the paths of filtered data in tFileCopy

    ReplyDelete
    Replies
    1. Can you explain what you are looking for - paths of filtered data in tFileCopy? which paths are you looking for and what are you filtering in iFileCopy

      Delete
    2. i wanted to copy filtered files in to different location, i finally figured out that we could get row7.file_name thanks for the really helpful tutorial

      Delete
  2. This way you read all filees. It seems to me a better way to set a global var depending with null or the filepath if NB_FILE == 1 and then make a RunIf if your globalVar is not null.

    ReplyDelete
  3. Thank you for your guide to with upgrade information about
    AWS keep update at AWS Online Course

    ReplyDelete
  4. How to get Last Modified File from a directory using tFTPGet

    ReplyDelete
  5. How to get Latest File from a directory using tFTPGet

    ReplyDelete