Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
asurbs19
Contributor
Contributor

Can tMap improve/replace tJavaRow solution

Hello

 

I am new to Talend and I wonder if there is a better way to complete task

.

 

I have expected results with a tJavaRow but wondering if another component can do the same. I've  heard it mentioned to use tJavarow only if no other component is available. I did not know how to configure tMap or another to get the same results.

 

// File is
//
// Name;Jim
// BD;1/2/1994
// Gender;M
// Name;Joe
// BD;2/12/1984
// repeating Name, BD, Gender

 

// Formatting to 
// Name BD Gender
// Jim 1/2/1994 M
// Joe 2/12/1984 M
// etc..

 

switch (row1.DataName){

case "Name":
context.ConcatValues = context.ConcatValues + row1.Value;
break;

case "BD":
context.ConcatValues = context.ConcatValues + "|" + row1.Value;
break;

case "Gender":
context.ConcatValues = context.ConcatValues + "|" + row1.Value + "\r\n";
break;

default:
break;

}

Labels (3)
1 Solution
3 Replies
asurbs19
Contributor
Contributor
Author

 

Thank you for the link,

I have reviewed and see the need to add a key to allow the pivot to work properly.

The Numeric.sequence in the suggestion creates:

0; Name;Jim
1; BD;1/2/1994
2; Gender;M
0; Name;Joe
1; BD;2/12/1984

2; Gender;M

 

for pivot to work I believe i need 

0; Name;Jim
0; BD;1/2/1994
0; Gender;M
1; Name;Joe
1; BD;2/12/1984

1; Gender;M

 

Can Numeric.sequence be configured to do such? 

 

 

asurbs19
Contributor
Contributor
Author

Thanks again, used tJavaRow to create the key i need to get the pivot i need

 

output_row.ID = context.Added4Pivot;
output_row.Name = input_row.Name;
output_row.Value = input_row.Value;
if (output_row.Name.equals("LastRepeatingRow")) {
context.Added4Pivot++;