Page 1 of 1
Selecting a particular row in a sequential file
Posted: Mon May 11, 2009 11:24 am
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!
Re: Selecting a particular row in a sequential file
Posted: Mon May 11, 2009 11:34 am
by reddysrc
use UNIX shell scripts and add in Before jobsubroutines.
Thanks
Rama
Posted: Mon May 11, 2009 12:20 pm
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.
Posted: Mon May 11, 2009 1:30 pm
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.
Posted: Tue May 12, 2009 4:13 am
by Sainath.Srinivasan
You can locate the nth record and read them alone using unix commands.
Posted: Tue May 12, 2009 5:34 am
by sivagnanamsv
we can use the sample stage to get the Nth record..?
Posted: Tue May 12, 2009 7:55 am
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.
Posted: Tue May 12, 2009 3:35 pm
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.