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

Announcements
Want to see what's currently in public preview? We've pulled it all together in one place. Check it out here
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

[resolved] Duplicate Rows based on a column value

Hi Guys,
I have a tricky job to do. Basically I want to change the number of tuples I have in a source component based on a number located into a filed. I explain:
Entry File
No Name Number
1 Dupont 4
Output File
No Name
1 Dupont
1 Dupont
1 Dupont
1 Dupont
Is there any simple trick I can use?
Another quick trick I require, I have a filed that looks like : ;;;;;;;1;;;;1;;;;1
And I would like to be able to addition those numbers... any java killer method could help?
Many thanks folks!
Labels (3)
1 Solution

Accepted Solutions
Anonymous
Not applicable
Author

Hello
Is there any simple trick I can use?

Yes, it is easy to finish in TOS. Here is a java senario:
in.csv:

1;Dupont;4
2;Shong;3

Result:
Starting job forum6760 at 10:53 27/05/2009.
1|Dupont
1|Dupont
1|Dupont
1|Dupont
2|Shong
2|Shong
2|Shong
Job forum6760 ended at 10:53 27/05/2009.

Best regards

shong

View solution in original post

7 Replies
Anonymous
Not applicable
Author

Another quick trick I require, I have a filed that looks like : ;;;;;;;1;;;;1;;;;1
And I would like to be able to addition those numbers... any java killer method could help?

String[] tab = ";;;;;;;1;;;;1;;;;1".split(";");
int result = 0;
for(String s : tab) {
if(s.matches("+")) {
result += Integer.parseInt(s);
}
}
Anonymous
Not applicable
Author

Hello
Is there any simple trick I can use?

Yes, it is easy to finish in TOS. Here is a java senario:
in.csv:

1;Dupont;4
2;Shong;3

Result:
Starting job forum6760 at 10:53 27/05/2009.
1|Dupont
1|Dupont
1|Dupont
1|Dupont
2|Shong
2|Shong
2|Shong
Job forum6760 ended at 10:53 27/05/2009.

Best regards

shong
c0utta
Creator
Creator

shong beat me to it, but I've used the tFor in my solution. Good use of the "Number of rows"in the tFixedFlowInput shong!
I think this proves that there are many ways to skin the cat when you've got such a great tool to work with.
.. I want to change the number of tuples I have in a source component based on a number located into a filed

Load the fields into context variables first.
Iterate using a tLoop, up to the count in the context variable.
Use a tFixedFlowInput to insert the context variables into the data stream.
I've used a tLogRow, but if you want the flow out to a file you'll need to make sure you append.
Cheers,
c0utta
Anonymous
Not applicable
Author

Guys, you all saved me!!! I 'll implement that today...
Remy (who loves this community...)
Anonymous
Not applicable
Author

Hello
Is there any simple trick I can use?

Yes, it is easy to finish in TOS. Here is a java senario:
in.csv:

1;Dupont;4
2;Shong;3

Result:
Starting job forum6760 at 10:53 27/05/2009.
1|Dupont
1|Dupont
1|Dupont
1|Dupont
2|Shong
2|Shong
2|Shong
Job forum6760 ended at 10:53 27/05/2009.

Best regards

       shong

how you do that ?
regards,
G.
Anonymous
Not applicable
Author

how you do that ?


The job design is as below:
tFileInputDelimited--main(row1)-->tFlowToIterate--iterate-->tFixedFlowInput--main--tLogrow
on tFixedFlowInput, set the number of Row field with the current Number value, for example:
(Integer)globaoMap.get("row1.Number")
About tFlowToIterate component, refer to the user manual:
https://help.talend.com/reader/JuYAu6ZYt6JnyC2yfuo83w/~aaaL9zPp0xMBTIBqNXMmw
Best regards
Shong

Anonymous
Not applicable
Author

Thank you very much 0683p000009MACn.png
You save my day!
Regards,
G.