Steve Diarrassouba
Steve Diarrassouba

Reputation: 53

How concatenate 2 column that contains multiple rows of data

I work with Talend 6.3. I want to concatenate 2 columns in tmap. But in specifics rows, there are multiple data and i want match them the first with the first of the row in the other column.

Example :

I want an other row that concatenates Kevin with Monta, Zoe with Rey, Alan with Zom.

How do that with talend? Because in tmap if I concatenate classic, I will have only one success concatenation.

I don't know if I explained that correctly but tell me if someone need more information.

Thanks in advance

The job :

enter image description here

Add other data -> Login is the ID

enter image description here

enter image description here

Upvotes: 0

Views: 962

Answers (3)

Carassus
Carassus

Reputation: 142

So we have a flow with an ID and 2 columns (Name and Surname), each contain n elements. n can vary from row to row.

The goal is to have a final flow with the concatenation of all Name + Surname with the ID intact.

It's not a super Talend-y way, but you can use tFlowToIterate to access each row individually and do the pairing of Name + Surname.

After, we access the resulting list and use tNormalize to split it :

screenshot job

Code for the tJava component :

List<String> nameList = Arrays.asList(((String)globalMap.get("row5.Name")).split("\\s*,\\s*"));
List<String> surnameList = Arrays.asList(((String)globalMap.get("row5.Surname")).split("\\s*,\\s*"));

for (int index = 0; index < nameList.size(); index++) {
    ((ArrayList<String>) context.concat).add(((Integer)globalMap.get("row5.id")) + ";" + nameList.get(index) + ";" + surnameList.get(index));
}

Code for the tFixedFlowInput "Use context (list)" :

StringHandling.EREPLACE(StringHandling.EREPLACE(context.concat.toString(),"\\[",""),"\\]","")

Result :
enter image description here

Upvotes: 1

Steve Diarrassouba
Steve Diarrassouba

Reputation: 53

That the code to set the global var with the list

That the code to get my list

enter image description here

And i have this result (the first have organisation empty, the first and the second have to have santeffi, don't look the first column, the second is the good one) enter image description here

that data before javaRow (code and libelle are in different column) enter image description here

Upvotes: 0

Steve Diarrassouba
Steve Diarrassouba

Reputation: 53

Sorry like that : enter image description here

The concatenation work when i have only one data in the column. Only Kevin and only Monta in cels. Maybe it's cause of my tDernormalize in the schema.

enter image description here

Upvotes: 0

Related Questions