I want to merge 2 inputfiles into one

Post questions here relative to DataStage Enterprise/PX Edition for such areas as Parallel job design, Parallel datasets, BuildOps, Wrappers, etc.

Moderators: chulett, rschirm, roy

Post Reply
bollinenik
Participant
Posts: 111
Joined: Thu Jun 01, 2006 5:12 am
Location: Detroit

I want to merge 2 inputfiles into one

Post by bollinenik »

Hi,

1st file input is
ClaimNo1|Version1|XX|xxxxxxx
ClaimNo2|Version1|XX|xxxxxxx
2nd file input is
ClaimNo1|Version1|itemno1|XX|xxxxxxx
ClaimNo2|Version1|itemno1|XX|xxxxxxx
Required output in single file is
ClaimNo1|Version1|XX|xxxxxxx
ClaimNo1|Version1|itemno1|XX|xxxxxxx
ClaimNo2|Version1|XX|xxxxxxx
ClaimNo2|Version1|itemno1|XX|xxxxxxx

Pls help me anyone
kOTI,
1586-738-7785
bollinenik
Participant
Posts: 111
Joined: Thu Jun 01, 2006 5:12 am
Location: Detroit

Post by bollinenik »

I am asking how to merge 2 files in that proper way into single file in Data stage parallel jobs
kOTI,
1586-738-7785
Sreedhar
Participant
Posts: 187
Joined: Mon Oct 30, 2006 12:16 am

Post by Sreedhar »

In Unix we have some thing called as file descriptor.
with that we can achieve your requirement.

exec 3<firstInputfile
exec 4<secondInputfile

while not EOF
do

read <&3 Var1
read <&4 Var2

echo Var1 >> Resultant File
echo Var2 >> Resultant File

done

recently we have come across this situation and achieved by this way.

So this should help you

Do look out for File descriptor
Regards,
Shree
785-816-0728
Nageshsunkoji
Participant
Posts: 222
Joined: Tue Aug 30, 2005 2:07 am
Location: pune
Contact:

Post by Nageshsunkoji »

Hi,

We can acheive your functionality by using funnel stage. If you perform sort funnel. If you want the result in the mentioned order in the sequentail manner. Select the execution mode as sequential and collect that by using sort merge method of collection. Because paralell sort will sort the data based on the keys and it will put the relevent data in the same node. So, if you want to see your output as
ClaimNo1|Version1|XX|xxxxxxx
ClaimNo1|Version1|itemno1|XX|xxxxxxx
ClaimNo2|Version1|XX|xxxxxxx
ClaimNo2|Version1|itemno1|XX|xxxxxxx
NageshSunkoji

If you know anything SHARE it.............
If you Don't know anything LEARN it...............
bollinenik
Participant
Posts: 111
Joined: Thu Jun 01, 2006 5:12 am
Location: Detroit

Post by bollinenik »

Is there any way in data stage
kOTI,
1586-738-7785
bollinenik
Participant
Posts: 111
Joined: Thu Jun 01, 2006 5:12 am
Location: Detroit

Post by bollinenik »

Thx nagesh,

Funnel will work if both the files will have same metadata here 2 input files metadata is different but key fields are same
In that way funnel won't work right.....So if you hane any other idea in this way pls let me know
kOTI,
1586-738-7785
caltog
Premium Member
Premium Member
Posts: 39
Joined: Thu May 22, 2003 7:32 am

Post by caltog »

Why you do not format both file with same metadata just before the funnel stage, with a transformer for example ?
bollinenik
Participant
Posts: 111
Joined: Thu Jun 01, 2006 5:12 am
Location: Detroit

Post by bollinenik »

Thx Caltog,

I did in that way but how i can define linkordering the firstfile record should be first in outputfile and the record from 2nd file should be 2nd in the sorting is there any way
kOTI,
1586-738-7785
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

The easiest way is to preprocess the files so that they each have two additional columns, the file indicator and the row number (both of these can be generated by the Sequential file stage using optional properties).
Sort on these.
You can drop those columns prior to your final write.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
chandra
Participant
Posts: 88
Joined: Sun Apr 02, 2006 6:50 pm
Location: India

Post by chandra »

Correct me if Im wrong !

Merge :-
I see there are four fileds in one file and 5 fields in other file .

and output required is 5 fields o/p.
ClaimNo1|Version1|?||XX|xxxxxxx
ClaimNo1|Version1|itemno1|XX|xxxxxxx
ClaimNo2|Version1|?||XX|xxxxxxx
ClaimNo2|Version1|itemno1|XX|xxxxxxx



Q 1:- can we subistitue the Question mark ..
if so u try with funnel.
chandra ,
Hyd
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

Is that your final output or you will be needing to use this file for further processing. If yes for further processing then add the extra column in the second file and use a funnel stage to cat both of these files.
If this is your final output then just cat it at the unix level by

Code: Select all

cat file1 file2 > file3
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

If you MUST use DataStage, use a Funnel stage and a Sort stage.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Post Reply