I want to merge 2 inputfiles into one
Moderators: chulett, rschirm, roy
-
- Participant
- Posts: 111
- Joined: Thu Jun 01, 2006 5:12 am
- Location: Detroit
I want to merge 2 inputfiles into one
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
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
1586-738-7785
-
- Participant
- Posts: 111
- Joined: Thu Jun 01, 2006 5:12 am
- Location: Detroit
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
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
Shree
785-816-0728
-
- Participant
- Posts: 222
- Joined: Tue Aug 30, 2005 2:07 am
- Location: pune
- Contact:
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
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...............
If you know anything SHARE it.............
If you Don't know anything LEARN it...............
-
- Participant
- Posts: 111
- Joined: Thu Jun 01, 2006 5:12 am
- Location: Detroit
-
- Participant
- Posts: 111
- Joined: Thu Jun 01, 2006 5:12 am
- Location: Detroit
-
- Participant
- Posts: 111
- Joined: Thu Jun 01, 2006 5:12 am
- Location: Detroit
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
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.
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.
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
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.
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
Hyd
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
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.
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact: