Selecting a particular row in a sequential 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
dscon9128
Participant
Posts: 25
Joined: Fri Jun 13, 2008 9:11 am

Selecting a particular row in a sequential file

Post by dscon9128 »

Hello Everyone,

I was just wondering if it was possible to read a specific record from a sequential file source stage. I know there is a filter clause which can help me eliminate headers, footers and so on but I was wondering if it would be possible to extract say JUST the nth row of a file.

Thanks!
reddysrc
Participant
Posts: 39
Joined: Mon May 30, 2005 3:19 pm

Re: Selecting a particular row in a sequential file

Post by reddysrc »

use UNIX shell scripts and add in Before jobsubroutines.

Thanks
Rama
nagarjuna
Premium Member
Premium Member
Posts: 533
Joined: Fri Jun 27, 2008 9:11 pm
Location: Chicago

Post by nagarjuna »

Hi ,

You can use the following command in filter option present in sequential file head -5 filename | tail -1.This will give 5th row .Also you can use rownumber option in sequential file stage and there by use some constraints or filter to get desired rownumber.
Nag
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Still, the answer to the question is 'no'. It's sequential media and thus somehow you have to read the first 8 records to get to the 9th one.
-craig

"You can never have too many knives" -- Logan Nine Fingers
Sainath.Srinivasan
Participant
Posts: 3337
Joined: Mon Jan 17, 2005 4:49 am
Location: United Kingdom

Post by Sainath.Srinivasan »

You can locate the nth record and read them alone using unix commands.
sivagnanamsv
Participant
Posts: 6
Joined: Fri May 08, 2009 2:10 pm

Post by sivagnanamsv »

we can use the sample stage to get the Nth record..?
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

There are all kinds of ways to pick the record(s) you want from a sequential file input stream, including just the Nth record. Gonna go all anal here and reiterate that the answer to the question that was asked - I was just wondering if it was possible to read a specific record from a sequential file source stage - is still no. The only way to get to the Nth record in a sequential file is to read through all of the "N-1th" records first. Something has to do that.
-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 »

There is one way, and that is to use an ODBC driver for text files.

Just don't expect speed as well as functionality.
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