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

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
pawe84
Creator
Creator

delimiter output file with increasing file name

In this small example there is just a query which will export the values into a csv.

0683p000009M64M.png

 

The output file is called "List0.csv".

How I can use a counter so that next time when the job will started again
the output file would look like this "List01.csv".

And next time again "List02.csv" etc.


I tried to use tJavaFlex and the following code

int count= Integer.valueOf(counter);
context.Counter=count+1;
System.out.println(count);


but it's not working.

Or can I set a global variable which will increase?

Thanks for some ideas/hints.

Labels (4)
1 Solution

Accepted Solutions
Anonymous
Not applicable

Hi @pawe84 

 

Whenever you start the job the global variables/context set earlier will be flushed.

 

Hence the only way is to store the job count in a file, and in the pre job read the file/Table, add one more to the job count and store to context/Global Variable and use the same context/global variable to name the file.

 

After that again update the file/table with new value of the counter.

 

Thanks and Regards,

Subhadip

View solution in original post

4 Replies
Anonymous
Not applicable

Hi @pawe84 

 

Whenever you start the job the global variables/context set earlier will be flushed.

 

Hence the only way is to store the job count in a file, and in the pre job read the file/Table, add one more to the job count and store to context/Global Variable and use the same context/global variable to name the file.

 

After that again update the file/table with new value of the counter.

 

Thanks and Regards,

Subhadip

pawe84
Creator
Creator
Author

Now I tried to use tFileInputDelimited where I read a file with my star value.

Then the next component is tJavaRow with the following listing

 

context.count=input_row.seq;

context.count++;

 

But how I can get context.count now in order to save it tFileOutputDelimited? Which componend I have to use?

If I use tJavaRow again: output_row.seq=context.count it doesn't work I'll get an error.

 

pawe84
Creator
Creator
Author

Okay, now I got it.

I used tFixedFlowInput.

 

Is there a way tom reset the counter if a new day/ date is occuring?

E.g: Today the job was started five times --> stored value=5

 

When the job will be started tomorrow that there's a reset --> stored value=0 ? 

Anonymous
Not applicable

Hi,

 

   The best way is to store the date and running value to a database table (if not available, then use a control csv file).

 

    It should have two columns i.e., the date and current file sequence number. So at the beginning of your job, you will have to compare whether the date in the table(or file) is same as current date. If the condition is wrong, you can start the job with initial value i.e. 0. 

 

    If the condition for date is correct, you can assign the current value+1 to a context variable and use this value while creating the file name.

 

    Once the process is successfully completed, you need to insert both current date and current context value back to DB (or file) so that you can repeat the same process next time.

 

Warm Regards,
Nikhil Thampi

Please appreciate our Talend community members by giving Kudos for sharing their time for your query. If your query is answered, please mark the topic as resolved 🙂