merge three files

Post questions here relative to DataStage Server Edition for such areas as Server job design, DS Basic, Routines, Job Sequences, etc.

Moderators: chulett, rschirm, roy

Post Reply
ppalka
Participant
Posts: 118
Joined: Thu Feb 10, 2005 7:25 am
Contact:

merge three files

Post by ppalka »

I have three files:
- first file:
0,data
1,data
2,data
etc
-second file:
0,data
0,data
...
1,data
1,data
...
etc
-third file:
0,data
0,data
...
1,data
1,data
1,data
etc

And I need to merge that files by taking for each record from first file, all records with the same key from the second file and after that, all records from third file with the same key. In output file I need only data without keys (ids). How to do that?
Thanks in advance.

Best regards,
Piotrek
Sainath.Srinivasan
Participant
Posts: 3337
Joined: Mon Jan 17, 2005 4:49 am
Location: United Kingdom

Post by Sainath.Srinivasan »

Your question has the answer. User Merge stage.
ppalka
Participant
Posts: 118
Joined: Thu Feb 10, 2005 7:25 am
Contact:

Post by ppalka »

Sainath.Srinivasan wrote:Your question has the answer. User Merge stage.
I don't think so. I tried doing it by merge stage, but I didn't get the expected output. As I know merge will take data from first file and merge it with every record in the second with the same key. But I need only once to put data from first file, then only data from second file and then from third file. And so on for each record from first file.
Correct me if I am wrong about merge stage.
Sainath.Srinivasan
Participant
Posts: 3337
Joined: Mon Jan 17, 2005 4:49 am
Location: United Kingdom

Post by Sainath.Srinivasan »

Concatenate the 3 files and then sort.
ppalka
Participant
Posts: 118
Joined: Thu Feb 10, 2005 7:25 am
Contact:

Post by ppalka »

Sainath.Srinivasan wrote:Concatenate the 3 files and then sort.
But in output file there would be no ID field. ID field in source files is only for merging data. So it would be impossible to sort.
pnchowdary
Participant
Posts: 232
Joined: Sat May 07, 2005 2:49 pm
Location: USA

Post by pnchowdary »

Hi,

If you dont want the ID field in the ouput, pass your merged output thru a transformer and eliminate the ID field in it and then write to your final output.
Thanks,
Naveen
ppalka
Participant
Posts: 118
Joined: Thu Feb 10, 2005 7:25 am
Contact:

Post by ppalka »

How can I concatenate files? As I said before merge doesn't solve my problem.
pramod_au
Participant
Posts: 30
Joined: Thu Feb 06, 2003 8:30 am
Location: London,UK

Post by pramod_au »

Hi

Please give me a sample output of the merge file. I am not sure whether u want the merged file to look as:

$ cat merge
0,data0 0,data0 0,data0
1,data1 1,data1
2,data2

$ cat file1
0,data0
1,data1
2,data2

$ cat file2
0,data0
1,data1

$ cat file3
0,data0

$ paste file1 file2 file3 > merge


thanks
Pramod
Thanks
Pramod
ppalka
Participant
Posts: 118
Joined: Thu Feb 10, 2005 7:25 am
Contact:

Post by ppalka »

In this example I need to get this output:
file1.data0
file2.data0
file3.data0
file1.data1
file2.data1
file1.data2

I would like to do it in DS job.
Post Reply