Splitting a file.

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
srekant
Premium Member
Premium Member
Posts: 85
Joined: Wed Jan 19, 2005 6:52 am
Location: Detroit

Splitting a file.

Post by srekant »

Hi,

I have a scenario where i will be getting a source which is a result of appending of 2 files. Now when i read the file in datastage i have to split the file into 2 different files.

The file has 2 headers and the data from the first header to the starting of second header should go to one file and the data from second header should go to second file

Ex;

Code: Select all

Header1 12287898980
             A ,1, 2 , 1qwewew
             ....

             .....
Header2  1238909877
              b,e,t,234445,
....
...

I am using Datastage 7.5 EE and also the no of records keep on varying.
Sree
Kirtikumar
Participant
Posts: 437
Joined: Fri Oct 15, 2004 6:13 am
Location: Pune, India

Post by Kirtikumar »

Define a stage var whose value will 1 if the it has seen first header. Its value will change to 2 when it sees second header.
E.g.
RecordFromSVar

Code: Select all

If Inlink.HeaderCol = File1 Then
  1
Else
  If Inlink.HeaderCol = File2 Then
    2
  Else
    RecordFromSVar
Now on first link put constraint as:

Code: Select all

RecordFromSVar = 1
and on the second link put constraint as:

Code: Select all

RecordFromSVar = 2
Provided you records are ordered by headers.
Regards,
S. Kirtikumar.
rasi
Participant
Posts: 464
Joined: Fri Oct 25, 2002 1:33 am
Location: Australia, Sydney

Post by rasi »

Hi

One more important thing is to make sure that you process this step sequential.

Thanks
Regards
Siva

Listening to the Learned

"The most precious wealth is the wealth acquired by the ear Indeed, of all wealth that wealth is the crown." - Thirukural By Thiruvalluvar
Kirtikumar
Participant
Posts: 437
Joined: Fri Oct 15, 2004 6:13 am
Location: Pune, India

Post by Kirtikumar »

Oops!!! I missed that!!!
Thanks, sequential execution is very else you may get unexpected results.

But, if the data is partitioned and sorted on this HeaderCol, it will work with in parallel mode as well.
Regards,
S. Kirtikumar.
Post Reply