extract data from file different num of fields in each row

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

ShaneMuir
Premium Member
Premium Member
Posts: 508
Joined: Tue Jun 15, 2004 5:00 am
Location: London

Post by ShaneMuir »

Lucky wrote: Important thing is, the file will have only one Header and one Trailer records.
Ok now you have lost me again. Do you mean that you are processing one file at a time and each file only has one header record and one trailer record? If that is the case then do as Ray suggests, just check the file for a header and trailer using a shell script. And if you wanted to you could also top and tail the file in that script and just process the detail information.
Lucky wrote: Yes I meant Sort stage. I agree with your suggestion about the performance issues if we use a sort stage, but I am very new to data stage and still getting used it and still exploring the options available in DS. I have worked on Informatica so I am using that knowledge to create jobs in data stage. Having said that each tool is different in its own way, as you know.
Why would you need a sort stage?
Lucky
Participant
Posts: 31
Joined: Mon Oct 10, 2005 11:05 pm

Post by Lucky »

1. Agree with you that there is no need to use Sorter Stage as all the records are being collected into an intermediate file which is then being used as a Source.

2. I should process one file at a time and the file will have one Header and one Trailer record.

3. Platform being used is Windows. So I should go for batch scripts to check for the characters 'T', 'H' & 'D' by using find /c /i "T" command but I am not sure if I can rely on the script.
kumar_s
Charter Member
Charter Member
Posts: 5245
Joined: Thu Jun 16, 2005 11:00 pm

Post by kumar_s »

Hi Lucy,
If you were able to pre process, its fine. Else as the way Shane mentioned, have three streams from the transformer, each one for H, D and T.
And do a lookup in later stage for availability of both H and T.
Btw : Its 'Sort' in Datastage.
Impossible doesn't mean 'it is not possible' actually means... 'NOBODY HAS DONE IT SO FAR'
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Take two passes through the file. The first does nothing other than verify that each header record has detail and trailer records that belong to it. This is all done with stage variables and relies on the file being sorted (use a Sort stage if you need it). It might also populate a hashed file from the trailer records (use a constraint - record type = "T").

The second pass, in a separate job, ought then to be straightforward. But, since we still have no indication of your desired output format(s), it's difficult to suggest anything.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Kirtikumar
Participant
Posts: 437
Joined: Fri Oct 15, 2004 6:13 am
Location: Pune, India

Post by Kirtikumar »

What action needs to be taken if the H and T are not present?

If you want the file should be taken for processing only if it has H and T, then you can write control script around, which will use something like grep command to check if H and T are there. If yes, call job with this filename.

There are other options as well.
Regards,
S. Kirtikumar.
gomez
Premium Member
Premium Member
Posts: 83
Joined: Tue Jun 22, 2004 6:11 am

Post by gomez »

Hi All, this closely resembles my case but I have Header->Detail(s)->Trailer structure repeating in my source file. Target file would also have to be written the same order. How do I go about creating this ?
Any help on this is appreciated !

Thanks
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

I suggest starting a new post with a link referring to this particular post for referrence. This way we will know job type, os type and other information that will help others provide a solution.
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
gomez
Premium Member
Premium Member
Posts: 83
Joined: Tue Jun 22, 2004 6:11 am

Post by gomez »

Thanks for the suggestion.
I have opened a new thread on the issue I am facing

Code: Select all

http://www.dsxchange.com/viewtopic.php?p=215004#215004
Post Reply