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

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Merge two text files, row by row, to create one new column

Good day guys

I am having difficulty with a specific use case in Talend. I have simplified my problem a bit below:

I have two text files, one contains a list of names like so:

John

Peter

Sandra

 

The second file contains a list of surnames like so:

Williams

Alkema

Smith

 

The 2 files will always have the same number of records.

 

I need to join these 2 files together, line by line, like so:

John Williams

Peter Alkema

Sandra Smith

 

In Java this is rather straight forward. One can read the names into and array, and then the surnames into an array, and loop through them like so:

for (int i = 0; i < name_array.length(); i++)

{

   System.out.println (name_array[i] + " " + surname_array[i]);

}

 

But how can I do this in Talend? I need to write the combined string out to a file again.

 

Thank you

Labels (3)
1 Solution

Accepted Solutions
TRF
Champion II
Champion II

Here a solution:

0683p000009Lufu.png

 

0683p000009LugJ.png

tMap to add a sequence (you 2 with the same model):

0683p000009Lv46.png

tMap to join the records:

0683p000009Lutc.png

 

View solution in original post

6 Replies
Anonymous
Not applicable
Author

If you simply want to join them sequentially, you could add a sequence to each input (using tMap) and then use a third tMap to join them on sequence.

TRF
Champion II
Champion II

Here a solution:

0683p000009Lufu.png

 

0683p000009LugJ.png

tMap to add a sequence (you 2 with the same model):

0683p000009Lv46.png

tMap to join the records:

0683p000009Lutc.png

 

Anonymous
Not applicable
Author

Thank you to you both. You guys are too awesome! And thank you for building the job for me with screenshots, I really appreciate it.

 

I am back at work on Thursday and will try it out. I will let you guys know how it goes. 

TRF
Champion II
Champion II

@necrolingus, did you test the proposed solution?
Anonymous
Not applicable
Author

Hi there

 

I got around to testing the solution and it is working great.

 

I subsequently moved away from files and used a hashmap, and things are looking good!

TRF
Champion II
Champion II

Great!