Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
See why IDC MarketScape names Qlik a 2025 Leader! Read more
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Passing parameter Dynamically to file naming convention

HI,
files would be arriving on day to to day basis into UNIX directory, for example as mentioned below:
test.20160401,
test.20160402
if we are running job  for  20160401 then talend job should pick file test.20160401 if if we are running job  for  20160402  then talend job should pick file test.20160402.
so i want to pass time stamp as parameter to all files as extension for that job running date.
can you please help me how to achieve this task?
Thanks,
Bharath.K
Labels (2)
5 Replies
Anonymous
Not applicable
Author

Hi,
so i want to pass time stamp as parameter to all files as extension for that job running date.

Could you please elaborate your case with an example with expected output values?
 Here is a component tFileProperties which obtains information about the main properties of a defined file.
Best regards
Sabrina 
Anonymous
Not applicable
Author

Hi,
Below is the example for my requirement:
Below is the source file name present in the job(extension-timestamp(YYYYMMDD) should be appended with file)
Sourc file Name: sales.YYYYMMDD
if we running job on April 14 2016 then our job looks file name as sales.20160414 in the directory
if we running job on April 20 2016 then our job looks file name as sales.20160420 in the directory
so whenever we running job how to pass dynamically timestamp as parameter to file name as extension?
Thanks,
Bharath.K
talendtester
Creator III
Creator III

Are you running your job at the end of the work day?
String.valueOf(  TalendDate.getDate("yyyyMMdd") );
If you need to wait for the day to be over and calculate yesterday's date to process the sales from yesterday it would look like this:
String.valueOf(  TalendDate.addDate(TalendDate.getDate("yyyyMMdd"), "yyyyMMdd",-1,"DD")  )  );
Anonymous
Not applicable
Author

no, we are running job every day, but i want to pass file name dynamically insted of hard code name in the jobs.
how we can implement this?
Anonymous
Not applicable
Author

Use a context variable or a globalMap variable for the filename. The context variable or globalMap variable will need to be set in a subjob prior to the one where the variable is being used to open the file.