Page 1 of 1

logic on group number

Posted: Wed Sep 15, 2010 2:56 pm
by dodda
Hello

I have a requirement where i need to read the data from seq file and write it to a seq file. i am using transformer and running the transformer sequentially.

I am using a job parameter called group number. If the group number is 4 then i need to create additional column called group number and assin the values as below.

lets say i am extracting 10 rows from input file (a,b,c,d....). The out out should be

Col1 GroupNbr
a 1
b 1
c 1
d 1
e 2
f 2
g 2
h 2
i 3
j 3

and so on.

Need help on how to get this grp numbers. This group number parametr i am passing as a job parameter and this can be any number.




Regards

Posted: Wed Sep 15, 2010 3:16 pm
by chulett
Yet another chance to use stage variables to control that, something very similar to what was just posted here I would wager:

viewtopic.php?t=135971

Posted: Wed Sep 15, 2010 3:21 pm
by dodda
hello chulett,

This is different logic i have to assign one disticnt number for every 4 rows and there is no identifer to differentiate the change of value from the input stream

Thanks

Posted: Wed Sep 15, 2010 3:22 pm
by chulett
It's not all *that* different, you simply reset on a count rather than a key change.

Posted: Wed Sep 15, 2010 4:01 pm
by dodda
i accomplished it by dividing the rownum with the job parameter and applying ciel function.

Thanks

Posted: Wed Sep 15, 2010 4:59 pm
by chulett
That sounds like one solution, a Mod() would have worked as well, I would think. Or a simple counter checking against the parameter value. As usual, more than one way to skin the cat. :wink:

Posted: Thu Sep 16, 2010 12:46 am
by agpt
dodda wrote:i accomplished it by dividing the rownum with the job parameter and applying ciel function.

Thanks
Can you please tell how exactly you assigned one number to 4 conscutive rows?