Removing Last row from Input File

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
ketanshah123
Participant
Posts: 88
Joined: Wed Apr 05, 2006 1:04 am

Removing Last row from Input File

Post by ketanshah123 »

Hi
If I want to remove the last row from my input file then how can I implement in DS server job?
I want to remove row at runtime.
JoshGeorge
Participant
Posts: 612
Joined: Thu May 03, 2007 4:59 am
Location: Melbourne

Post by JoshGeorge »

If you have MKS Toolkit or similar installed you can try the below said.

To remove just the last line from your file 'at runtime' use this command in your filter option of sequential file satge:

Code: Select all

 sed -e '$d' 
Joshy George
<a href="http://www.linkedin.com/in/joshygeorge1" ><img src="http://www.linkedin.com/img/webpromo/bt ... _80x15.gif" width="80" height="15" border="0"></a>
kcbland
Participant
Posts: 5208
Joined: Wed Jan 15, 2003 8:56 am
Location: Lutz, FL
Contact:

Post by kcbland »

To have your job know the last row it needs to know how many rows are in the input file. Using a "wc -l" command (checkout CYG/Win or MKS Toolkit) you can pass the row count in and then use a simple constraint check.

Otherise, you'll have to be creative and use a SEQ-->AGG-->HASHed file portion of job design to read the sequential file, count() using the aggregator the number of rows and then write to a hashed file. Then a simple reference to the hashed file (pre-load to memory) and use of constraint in a transformer stage comparing the the @INROWNUM value to the referenced value and output when not the same will do the trick.
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
Post Reply