Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
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:-
testout1.csv
Looking forward for some ideas .
Thanks.
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.
tFixedFlowInput_2 has the same schema as source data (tFixedFlowInput_1 in this case), it generates the current row of data.tUnite: merge all the rows before they are written into file.
Please try and let me know if you have any questions.
Regards
Shong
Thanks for the information, I will try to figure it out for more. Keep sharing such informative post keep suggesting such post.
Many thanks to you Shong for providing an example as well.
I will try to out the components suggested and get back soon.
Hi 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.
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.