Page 1 of 1

Row count generation

Posted: Mon May 19, 2008 9:30 am
by Vino_joe84
Hi,

We have a requirement in which we need to seperate the 10th record from a file and process it separately. Is there any way to filter the 10th record alone from a file using any stages by checking the rowcount . Any help is appreciated. Thanks

Posted: Mon May 19, 2008 10:14 am
by ArndW
Use "@INROWNUM" in a transform stage. Easiest if you change your job to use just one node or work sequentially in that stage.

Posted: Mon May 19, 2008 10:21 am
by chulett
And on the off chance you mean every 10th record, then a MOD() could be used... assuming that is available in PX.

Posted: Mon May 19, 2008 12:31 pm
by ag_ram
This may be what you want in the contraint as both said:

Code: Select all

Not(Mod(@INROWNUM,10))

Posted: Mon May 19, 2008 5:30 pm
by ray.wurlod
Keep in mind (and in your design) the consequences of parallel execution. Is "the tenth record on each node" what you require, or "the tenth line from a sequential file (being processed sequentially)" what you require?

Posted: Tue May 20, 2008 7:07 am
by throbinson
Use the filter property in the Sequential Stage
awk 'NR == 10'

although I like the @INROWNUM better.

Hey, this is fun. I'll bet there aren't more then 10 more different ways to do it.

Posted: Tue May 20, 2008 7:46 am
by OddJob
Use an External Source stage with the following command:
head -10 <file name> | tail -1

Posted: Tue May 20, 2008 8:01 am
by ray.wurlod
Use a Copy stage with a Sample stage on the second output.

(Come on, keep 'em coming - the target is ten ways!)

Posted: Tue May 20, 2008 8:50 am
by OddJob
Using a Sequential File stage, add option 'Row Number Column' and follow up with a Filter stage only allowing through Row Number = 10.

Posted: Tue May 20, 2008 8:55 am
by Azzuri
Use transformer stage(Run sequentially) with a stage variable counting the number of rows. In contraints put where svCount <> 10 on output.

Posted: Tue May 20, 2008 9:21 am
by throbinson
1. Use row Number Option in Sequential Stage.
2. Define a lookup to Oracle with SELECT 10 As rowNumber from Dual as User Defined SQL.
3. Join to Row Number from Sequential Stage. Condition Not Met - Drop
4. Update your resume.

Posted: Tue May 20, 2008 2:49 pm
by tscala
1-Open file in Notepad.
2-Count down to 10th record.
3-Highlight record using mouse.
4-Ctl+C
5-Open blank document using Notepad.
6-Ctl+V
7-Save file and note location.
8-Run job using file as input.

Posted: Tue May 20, 2008 4:42 pm
by ray.wurlod
Notepad would be a good trick on UNIX. However, in vi you can use :set nu to make line numbers visible, and yank the appropriate row (line) from the file.

Posted: Tue May 20, 2008 9:17 pm
by tsn
There are many ways,

If you use transformer stage then,
you either use @INROWNUM or OUTROWNUM, based on the requirement, if you want to take out 10th record which got processed to the target the use @OUTROWNUM or if you want to take out 10th record from the file then use @INROWNUM
Use @OUTROWNUM=10 in the constraint of the transformer stage.

you can you use head -11 <filename> also. Use this if your source file has header record init.

tks.