Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content
Announcements
March 26 at 10am ET: See how Qlik drives growth and value in ISV segment - REGISTER NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
gfoo-009
Contributor
Contributor

Create new file using loop

Hi ,

I need to create new records on new file from a given input file using Talend.

Anybody got any ideas how this can be achieved using talend component like loop or

others ?

The purpose is to read the input file with 3 rows and depending on the qty on

each row ,populate the x number of lines as indicated by the quantity on each row.

In this example first row has qty 5 will produce 5 lines of same record with qty 1 .

and 2nd row with 3 lines ....3rd row with 1 line.

Example input file test.csv with 3 rows:-

0695b00000StErLAAV.png

testout1.csv

0695b00000StErVAAV.png

Looking forward for some ideas .

Thanks.

Labels (4)
5 Replies
Anonymous
Not applicable

Hi

Iterate the source data row by row and use a tLoop component to do the loop, generate qty rows of the same data. Here is an example Job.

0695b00000StFKhAAN.png

tFixedFlowInput_2 has the same schema as source data (tFixedFlowInput_1 in this case), it generates the current row of data.0695b00000StFKcAAN.pngtUnite: merge all the rows before they are written into file.

 

Please try and let me know if you have any questions.

 

Regards

Shong

Daniel044
Contributor II
Contributor II

 Thanks for the information, I will try to figure it out for more. Keep sharing such informative post keep suggesting such post.  

gfoo-009
Contributor
Contributor
Author

Many thanks to you Shong for providing an example as well.

I will try to out the components suggested and get back soon.

gfoo-009
Contributor
Contributor
Author

0695b00000StM0AAAV.pngHi Shong, if I use tFileInputDelimited_1 instead of tFixedflowinput as there can be hundreds of records or rows to process. Do I still need tloop?

I need to be able increment the count as iteration is being done on first loop:-

Pseudo codes will be like:-

for each wf-det :

do I =1 to wf-det.wf-qty :

create wf-det2.

cnt = cnt + 1

wf-det2.wf-seq = cnt

Wf-det2.wf-prod2id = wf-det.wf-prod2id

.....

.....

end.

end.

Will the above components achieve the intended output i.e

On processing first row of input file,

5 line items will be created ..then 3 line and then 1 line.

Anonymous
Not applicable

tFileInputDelimited or tFixedFlowInput are both input component that read data from data source, tloop is used to duplicate the same row multiple times based on the qty value. From your example data, qty value is read from the source data.