Duplicate in rows in the output row

Four Stars

Duplicate in rows in the output row

Hi everybody.

 

I've got an entry flow, and I have to deplicate some rows.

More precisely, in my input there is a field that specified how many time I have to duplicate the row.

 

For exemple, my input is:

product;number

book;2

coat;0

plate;3

 

My output needs to be:

product

book

book

plate

plate

plate

 

Does anyone have any thought ?

 


Accepted Solutions
Eleven Stars

Re: Duplicate in rows in the output row


you can create an empty file,
use flowtoiterate and a tloop to add ntime the same data to the previous file.

Francois Denis

Tag as "solved" for others! Kudos to thanks!


All Replies
Eleven Stars

Re: Duplicate in rows in the output row

select the max number (maybe you know it)
create a temp table like
1
2
2
3
3
3
4
4
4
4
and use tmap to join use "all row"

Francois Denis

Tag as "solved" for others! Kudos to thanks!

Eleven Stars

Re: Duplicate in rows in the output row


you can create an empty file,
use flowtoiterate and a tloop to add ntime the same data to the previous file.

Francois Denis

Tag as "solved" for others! Kudos to thanks!

Eleven Stars

Re: Duplicate in rows in the output row

take the max number or you may know it . Create a table or a fil containing:
122333444455555666666.....
and use a tmap to join using "all match"

Francois Denis

Tag as "solved" for others! Kudos to thanks!

Forteen Stars TRF
Forteen Stars

Re: Duplicate in rows in the output row

Forget this post, other screen captures have been lostCapture.PNG


TRF
Sixteen Stars

Re: Duplicate in rows in the output row

1) Join your data as the Main flow to a tMap.

2) As the Lookup, join a tJavaFlex with a single int column ("number")

3) Inside the tMap, join the "number" column on your Main to the "number" column on your Lookup. Set the "Lookup Model" to "Reload at Each Row", the "Match Model" to "All Matches" and the "Join Model" to "Inner Join".

4) You will see a "globalMap Key" section appear. Click the green plus symbol and call the "globalMap Key" "count" and link your "number" column from your Main row to it.

5) Create an output table and link your "Product" record.

6) In your tJavaFlex (assuming you have already created your "number" column, add the following code to the Start Code.....

// start part of your Java code
int count = ((Integer)globalMap.get("count"));

for(int i = 0; i<count; i++){

7) Add this to your Main Code....

row18.number = count;

Note: row18 is just in my example. Yours will have to match the row name coming out of the tJavaFlex

8) Add this to your End Code....

}

 

Your job will look like this (I'm using a tFixedFlowInput to simplify my example)....

 

Job124.png

 

Your tMap will something like this......

 

tmap123.pngWhen you run this, the row will be multiplied by the number supplied on it. If the number is 0, then no row will be output.

 

Four Stars

Re: Duplicate in rows in the output row

Thanks everybody for your help.

 

I've impleted the fdenis's solution : 

tFlowToIterate -> tLoop -> tIterateToFlow

with in the tLoop , input.numberinto the "To" field

It's work well and the entries with (input.number == 0) are abandoned.

 

Great thanks to rhall_2_0 for your exhaustive explanation.

Your solution seems more smart and with less components; I will try it later.

Four Stars

Re: Duplicate in rows in the output row

I've impleted this solution :

tFlowToIterate -> tLoop -> tIterateToFlow

with in the tLoop , input.numberinto the "To" field

It's work well and the entries with (input.number == 0) are abandoned.