Page 1 of 1

I want to merge 2 inputfiles into one

Posted: Wed Nov 29, 2006 3:38 am
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

Posted: Wed Nov 29, 2006 4:08 am
by bollinenik
I am asking how to merge 2 files in that proper way into single file in Data stage parallel jobs

Posted: Wed Nov 29, 2006 4:35 am
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

Posted: Wed Nov 29, 2006 5:01 am
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

Posted: Wed Nov 29, 2006 5:01 am
by bollinenik
Is there any way in data stage

Posted: Wed Nov 29, 2006 5:15 am
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

Posted: Wed Nov 29, 2006 6:06 am
by caltog
Why you do not format both file with same metadata just before the funnel stage, with a transformer for example ?

Posted: Wed Nov 29, 2006 7:43 am
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

Posted: Wed Nov 29, 2006 2:11 pm
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.

Posted: Fri Dec 01, 2006 1:24 pm
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.

Posted: Fri Dec 01, 2006 1:33 pm
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

Posted: Fri Dec 01, 2006 3:01 pm
by ray.wurlod
If you MUST use DataStage, use a Funnel stage and a Sort stage.