create output file w/ dynamic filename

One Star

create output file w/ dynamic filename

How do we create a filename "%JOBNAME%_%TIMESTAMP%.csv" dynamically and use it to store data from a table in a directory. The path can be passed into a job as a variable.
One Star

Re: create output file w/ dynamic filename

Use the following code in java:
jobName + "_" + TalendDate.formatDate("yyyyMMddHHmmssSSS", TalendDate.getCurrentDate()) + ".csv"
Employee

Re: create output file w/ dynamic filename

in a Perl project:
$_globals{job_name} . '_' . getDate('CCYYMMDDhhmmss') . '.csv'

in a Java project:
jobName + "_" + TalendDate.formatDate("yyyyMMddHHmmss", new Date()) + ".csv"
Employee

Re: create output file w/ dynamic filename

Please note that you can find global variables and usable function using auto-completion CTRL+space in any text field.
One Star

Re: create output file w/ dynamic filename

What about if i want to create a filename for each row, with the content of the columns?
For example i have this input info 
(row1) calculoMasivosResumen;2016-02-10;14:01:01
(row2) calculoTemporalGes;2016-02-10;14:07:41
(row3) controlComisionesTardia;2016-02-10;14:05:04
I want a file name called calculoMasivosResumen_2016-02-10_14:01:01.txt, another file called   calculoTemporalGes_2016-02-10_14:07:41.txt and other called controlComisionesTardia_2016-02-10_14:05:04.txt
I'm clear?
Thank you in advance for your help.
One Star

Re: create output file w/ dynamic filename

I've got the same question, I want to create over 30 files one per specific ID, however I would like to do it without creation of 30 tMaps outputs..
example: outputFilename: context.talendPath+"Projects/DWH/test_"+row7.id+".csv"
however this solution or using globalMap, creates only file for first id and then it's fixed.
One Star

Re: create output file w/ dynamic filename

Hello Diego, 
I just want to let you know that thanks to stackoverflow Ive found solution:
http://stackoverflow.com/questions/25684433/how-to-create-multiple-output-files-in-talend-based-on-a...
After reading this I got a main design in my head.
it is not the fastest solution but it works like a charm. let me know if you have any further questions.
One Star

Re: create output file w/ dynamic filename

Thx for sharing!
One Star

Re: create output file w/ dynamic filename

Hi dirk, let me know if you will need help. Ive everything tested and working on prod site.
Sixteen Stars

Re: create output file w/ dynamic filename

I demonstrate an easy way of doing this in this tutorial (https://www.rilhia.com/tutorials/load-data-dynamic-number-files)