#1 2007-12-27 06:51:07

sea2sky
New member
Registered: 2007-12-02
Posts: 5

Merge two files

Tags: [file, java, merge]

I have one file contains multiple columns for a table and the second file contains the rest of the columns. I would like to concatenate the columns in the first file with the columns of the corresponding rows in the second file. I do not have a key to join them for each row. Can this be done with TOS? How? If not, are there any other ways to do it?

Thanks.

Offline

#2 2007-12-27 07:04:31

shong
Talend team
Registered: 2007-08-29
Posts: 10299
Website

Re: Merge two files

Hi

It can be  finished with tMap component. Please download the user guide documentation and learn more.
Feel free to post your questions!

Best regards

         shong


Email:shong@talend.com
Choose Talend, Enjoy Talend!
New & Event: Talend Help Center
Talend-->the leader of open source data management and application integration solutions!

Offline

#3 2007-12-27 09:35:04

plegall
Member
Registered: 2006-09-19
Posts: 1586
Website

Re: Merge two files

sea2sky wrote:

I do not have a key to join them for each row.

So you mean, file1 row1 corresponds to file2 row1 and so on? I'm sorry, tMap can't do this (and TOS can't do this in a more general way). I suggest you to create a feature request in the bugtracker.

Offline

#4 2008-01-09 07:40:03

c0utta
Member
Registered: 2007-04-13
Posts: 134

Re: Merge two files

Hi sea2sky,

This can be done using 2 tMap components together with the sequence() function to generate unique (but sequential) keys for each data flow. This will provide you with an additional column representing the line number of each row. In another tMap, join the sequences (line numbers) together and voila!  Make sure you choose two different sequences (s1 and s2)

alpha.txt
a
b
c

num.txt
1
2
3

Starting job merge at 16:38 09/01/2008.
a1
b2
c3
Job merge ended at 16:38 09/01/2008. [exit code=0]

Cheers,

c0utta


Uploaded Images

Last edited by c0utta (2008-01-09 07:41:25)

Offline

#5 2008-01-09 10:21:43

plegall
Member
Registered: 2006-09-19
Posts: 1586
Website

Re: Merge two files

Excellent c0utta, that's a smart workaround. Would you like to write a use case on this subject? (as what you can find on [wiki] use cases)

Offline

Board footer

Powered by FluxBB