One Star

How to do a loop on a column value

Hello,
I need to build an output table with a number of rows coming from a input column.
Here my input table
Category;Number
***************
Cat1;2
Cat2;3
I need to create in the output table 2 rows for the first, 3 for the next, etc..
I've created a job to create the output rows, and I've tried to read my input table with a tfileinputdelimited and iterate on a tfor component giving $tfileinputdelimited as the limit and a trunjob to execute the first job in each loop.
It doesn't work, but I think I'm wrong with my understanding of the tfor component.
Thanks to lead me on the right way....
Louis
2 REPLIES
Community Manager

Re: How to do a loop on a column value

Hi Louis
Can you upload a screenshot of your job? and what's the format do your expected output?
Best regards
shong
----------------------------------------------------------
Talend | Data Agility for Modern Business
One Star

Re: How to do a loop on a column value

Hi,
You can use this pattern :
(A) tFileInputDelimited_1 -> (B) tFlowToIterate_1 -> (C) tRowGenerator_1 -> (D) tIterateToFlow_1 -> (E) tLogRow_1
with
(B) : check "use the default (key, value) for global variables"
(C) :
- Schema :
Column | Type | Function | Params
--------------------------------------------
Category | String | ... | (String) globalMap.get("row1.Category")

and
- Number of Rows for RowGenerator = (Integer) globalMap.get("row1.Number")