Remove header and footer(first and last line)

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
Ujjwal
Participant
Posts: 4
Joined: Wed May 11, 2005 11:26 pm

Remove header and footer(first and last line)

Post by Ujjwal »

Hi all,
My source file having header in first line and tailer in last line
so i want to remove first and last record using DS(parallel Extender ) if any one know please suggest


Regards
Ujjwal
kcbland
Participant
Posts: 5208
Joined: Wed Jan 15, 2003 8:56 am
Location: Lutz, FL
Contact:

Post by kcbland »

Write a ksh script that uses the results of a wc -l to issue the appropriate head and tail commands, streaming to stdout. Put that ksh into the filter on the Sequential stage.
Kenneth Bland

Rank: Sempai
Belt: First degree black
Fight name: Captain Hook
Signature knockout: right upper cut followed by left hook
Signature submission: Crucifix combined with leg triangle
kollurianu
Premium Member
Premium Member
Posts: 614
Joined: Fri Feb 06, 2004 3:59 pm

Post by kollurianu »

Hi Kenneth,


could you please give the steps briefly what is to be done in the shell script.to strip off the headers and and trailers , just curious

Thank you,
Purna.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Do you really need to do that in PX? The metadata won't match for the header and trailer records (assuming you are using the metadata from the detail records) so the Sequential stage should automatically 'reject' those two... right?
-craig

"You can never have too many knives" -- Logan Nine Fingers
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

... then the reject link could feed a stream that accepts the header but rejects the footer, and these streams could then be processed appropriately!
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
kumar_s
Charter Member
Charter Member
Posts: 5245
Joined: Thu Jun 16, 2005 11:00 pm

Post by kumar_s »

Hi Purna,
The scripts has been already provided in this forum. Pls do a search.

Hi Ujjwal,
The reject method work fine but with warnigs. If you are ready to accept warnigns, Ken's method is best.

-Kumar
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

I don't recall the 'reject method' causing any warnings. It will rather happily process any records that fail the metadata check into oblivion without raising any kind of a fuss. :wink:

Perhaps it's only after you actually setup a reject link? In this case, it doesn't sound like that would be needed.
-craig

"You can never have too many knives" -- Logan Nine Fingers
kumar_s
Charter Member
Charter Member
Posts: 5245
Joined: Thu Jun 16, 2005 11:00 pm

Post by kumar_s »

But i wonder how iam getting the following warining if i approach reject mechanism.

Code: Select all

SEQ,0: Short input record
SEQ,0: Import warning at record 0.
SEQ,0: Import unsuccessful at record 0.
Is there any other smarter approach to get rid of Short input record - read.

-Kumar
kcbland
Participant
Posts: 5208
Joined: Wed Jan 15, 2003 8:56 am
Location: Lutz, FL
Contact:

Post by kcbland »

This is a point of style.

Relying on the stage to behave poorly (IMO), meaning to silently toss data, is poor style.

You should affirmatively handle all data. If you don't want a row, build the logic to purposely remove the remove. If yo do want specific rows, build the logic to purposely include only those rows.

Letting the job "lose" data because it's the header and footer means that potentially in the future Ascential could change the behavior of the stage and now because you don't have affirmative logic unexpected things start happening.

For example, if you use a constraint to say you only want rows where a code value is A thru Z except for X, a lazy programmer might say: inlink.column NE 'X'. This serves the purpose that Xs don't make it in, but also allows '!' and 'x' and 'XX' to go thru. The affirmative logic would be to name all values A to Z except X in the constraint.

It's style but the korn shell script is a reusable solution. It's a generic script that can always be used to strip off the header and trailer record. It's even more beneficial if the header and trailer has row counts and checksum information, because then the script can validate the file first and return a non-zero value stopping the job if the file is corrupted. See the expandabilities?
Last edited by kcbland on Sat Nov 19, 2005 8:46 am, edited 1 time in total.
Kenneth Bland

Rank: Sempai
Belt: First degree black
Fight name: Captain Hook
Signature knockout: right upper cut followed by left hook
Signature submission: Crucifix combined with leg triangle
dspxlearn
Premium Member
Premium Member
Posts: 291
Joined: Sat Sep 10, 2005 1:26 am

Post by dspxlearn »

Hi all,

Do we have 'Stage using filter command' option in Parallel jobs in the sequential file stage like we have in Server jobs. If yes where can we enable that option. :lol:
Thanks and Regards!!
dspxlearn
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

dspxlearn - Please don't hijack other peoples threads. If you've got an new question, start a new post.

Ken, agree on your 'point of style'. Was primarily looking for a clarification / confirmation on how the stage actually works as I don't have access to a PX server. Just have a Ray Wurlod Guinea Pig Merit Badge, Texas Chapter. :wink:
Last edited by chulett on Sat Nov 19, 2005 1:57 pm, edited 1 time in total.
-craig

"You can never have too many knives" -- Logan Nine Fingers
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Spelling!!! :evil:
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Doh... at first I thought you meant 'Guinea' as in pig, but had checked that before posting. Finally dawned on me I was closer to Warlord than to Wurlod. :lol:

Sorry about that Chief... corrected.
-craig

"You can never have too many knives" -- Logan Nine Fingers
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Merci beaucoup
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Post Reply