Unique requirement to combine two files
Moderators: chulett, rschirm, roy
Unique requirement to combine two files
Hi,
I have a requirement to combine records from two input files, none of which is a Master. I want records from both merged, but on the same line.
Input file 1
53,red
53,blue
55,black
57,orange
57,violet
Input file 2
53,boy
53,cat
53,dog
54,pig
55,rat
56,girl
Expected Output is
53, red, boy
53, blue, cat
53, ,dog
54, , pig
55,black,rat
56, , girl
57, orange,
57, violet,
Any help is appreciated. Thanks.
I have a requirement to combine records from two input files, none of which is a Master. I want records from both merged, but on the same line.
Input file 1
53,red
53,blue
55,black
57,orange
57,violet
Input file 2
53,boy
53,cat
53,dog
54,pig
55,rat
56,girl
Expected Output is
53, red, boy
53, blue, cat
53, ,dog
54, , pig
55,black,rat
56, , girl
57, orange,
57, violet,
Any help is appreciated. Thanks.
-
- Premium Member
- Posts: 45
- Joined: Fri Nov 07, 2008 12:22 pm
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
A full outer join would be needed to achieve all of the output specified. Other than that quibble I, too, would recommend using a Join stage.ArndW wrote:Why not use an inner join in a join stage or a lookup stage (choose either link as a master) and have both Col2's go to the output?
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Hi Reddy,
I/P file 2------- >Join Stage--------->Target
I/P file1-------->(connect this link to Join Stage)
Set the properties of Join stage as follows:
Key:column containing value 53,54 etc
Join Type:left outer join
Link ordering:
---------------
Left:Link from I/p file 2
Right:Link from I/p file1
Try this.
Regards,
Raja R P
I/P file 2------- >Join Stage--------->Target
I/P file1-------->(connect this link to Join Stage)
Set the properties of Join stage as follows:
Key:column containing value 53,54 etc
Join Type:left outer join
Link ordering:
---------------
Left:Link from I/p file 2
Right:Link from I/p file1
Try this.
Regards,
Raja R P
Just join the Key column with full outer join.This will give the desired output.
a. Input1 (fa,fb)
b. Input2 (fc,fd)
c. Join fa,fc (full outer join)
d. Pull fk(fa,fb),fc,fd to target.
Regards,
Divya
a. Input1 (fa,fb)
b. Input2 (fc,fd)
c. Join fa,fc (full outer join)
d. Pull fk(fa,fb),fc,fd to target.
Regards,
Divya
Last edited by dxk9 on Fri Sep 04, 2009 2:32 am, edited 1 time in total.
-
- Participant
- Posts: 3337
- Joined: Mon Jan 17, 2005 4:49 am
- Location: United Kingdom
Re: Unique requirement to combine two files
reddy wrote:Hi,
I have a requirement to combine records from two input files, none of which is a Master. I want records from both merged, but on the same line.
Input file 1
53,red
53,blue
55,black
57,orange
57,violet
Input file 2
53,boy
53,cat
53,dog
54,pig
55,rat
56,girl
Expected Output is
53, red, boy
53, blue, cat
53, ,dog
54, , pig
55,black,rat
56, , girl
57, orange,
57, violet,
Any help is appreciated. Thanks.
You can add the column say "Srno" to both the table in the transformer prior to the Join Stage. Data from both the table will look like
srno Column1 colum2
1,53,red
2,53,blue
1,55,black
1,57,orange
2,57,violet
and for second table
srno Column1 Column2
1,53,boy
2,53,cat
3,53,dog
1,54,pig
1,155,rat
1,56,girl
Logic to assign the values to "Srno" column as shown above is already posted on the forum.
You can use "FULL OUTER JOIN" in the join stage with key fields as "Srno" and column contains 53,54 ...
I hope this will give you the desired output.
RohitN
-
- Premium Member
- Posts: 783
- Joined: Mon Jan 16, 2006 10:17 pm
- Location: Sydney, Australia