Can tMap improve/replace tJavaRow solution

Highlighted
Four Stars

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;

}


Accepted Solutions
Fifteen Stars TRF
Fifteen Stars

Re: Can tMap improve/replace tJavaRow solution


All Replies
Fifteen Stars TRF
Fifteen Stars

Re: Can tMap improve/replace tJavaRow solution

Four Stars

Re: Can tMap improve/replace tJavaRow solution

 

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? 

 

 

Four Stars

Re: Can tMap improve/replace tJavaRow solution

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++;

2019 GARNER MAGIC QUADRANT FOR DATA INTEGRATION TOOL

Talend named a Leader.

Get your copy

OPEN STUDIO FOR DATA INTEGRATION

Kickstart your first data integration and ETL projects.

Download now

What’s New for Talend Summer ’19

Watch the recorded webinar!

Watch Now

Best Practices for Using Context Variables with Talend – Part 2

Part 2 of a series on Context Variables

Blog

Best Practices for Using Context Variables with Talend – Part 1

Learn how to do cool things with Context Variables

Blog

Migrate Data from one Database to another with one Job using the Dynamic Schema

Find out how to migrate from one database to another using the Dynamic schema

Blog