Need to pick latest file from specific file format.

Four Stars

Need to pick latest file from specific file format.

Hello Talend Helpers, 

May you please help me for getting the current file from directory. Lets see the scenario 

In Directory we have below files. 

ACBACKLOG2017QTR1-RUNDT-FEB152017.txt
ACBACKLOG2016QTR4-RUNDT-FEB252017.txt
ACBACKLOG2016QTR3-RUNDT-FEB252017.txt
ACBACKLOG2016QTR2-RUNDT-FEB182017.txt
ACBACKLOG2016QTR1-RUNDT-FEB182017.txt


We need to create a logic to pic only current file. Here we have ACBACKLOG2017QTR1-RUNDT-FEB152017.txt as latest file, because its having latest 2017 QTR 1 data. 

Also need to make sure that we have already processed previous file before picking the latest one.


Thanks 
GopsK

Moderator

Re: Need to pick latest file from specific file format.

Hi,
Here is a TalendHelpCenter:tFileList component which retrieves a set of files or folders based on a filemask pattern and iterates on each unity.
You can choose to prioritise the folder and file order either by using "Order" option.
Best regards
Sabrina
--
Don't forget to give kudos when a reply is helpful and click Accept the solution when you think you're good with it.
Forteen Stars

Re: Need to pick latest file from specific file format.

Simplest logic:
[list=*]
  • process file

  • move processed file to archive folder (or rename it, or delete)


  • More intelectual - construct file name pattern for input component
    Like:

    "ACBACKLOG"+TalendDate.formatDate("yyyy",TalendDate.getCurrentDate())+"QTR"+((Integer.valueOf(TalendDate.formatDate("MM",TalendDate.getCurrentDate()))-1)/3+1)+"*.txt"
    -----------

    2019 GARNER MAGIC QUADRANT FOR DATA INTEGRATION TOOL

    Talend named a Leader.

    Get your copy

    OPEN STUDIO FOR DATA INTEGRATION

    Kickstart your first data integration and ETL projects.

    Download now

    What’s New for Talend Summer ’19

    Watch the recorded webinar!

    Watch Now

    Best Practices for Using Context Variables with Talend – Part 2

    Part 2 of a series on Context Variables

    Blog

    Best Practices for Using Context Variables with Talend – Part 1

    Learn how to do cool things with Context Variables

    Blog

    Migrate Data from one Database to another with one Job using the Dynamic Schema

    Find out how to migrate from one database to another using the Dynamic schema

    Blog