Reputation: 53
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 :
2 columns : Name and Surname
In Name, I have : Kevin,Zoe,Alan
In Surname, I have : Monta,Rey,Zom
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 :
Add other data -> Login is the ID
Upvotes: 0
Views: 962
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 :
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(),"\\[",""),"\\]","")
Upvotes: 1
Reputation: 53
That the code to set the global var with the list
That the code to get my list
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)
that data before javaRow (code and libelle are in different column)
Upvotes: 0
Reputation: 53
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.
Upvotes: 0