i have three columns in seq file as follows but i need the out put int he following way .Two extra columns required as per requirement GROUP and FAMILY
Name Phone_desc Phone_number GROUP FAMILY
ABC work 123-456-789 1 Y
XYZ CELL 857-657-798 2 N
GHI WORK 123-456-789 1 Y
IF NAME : ABC AND GHI having same phone number then it should come under group 1 and FAMILY is also "Y" for both of them.
Similarly if XYZ is having different cell the group should be 2 and family is "N"
In nutshell the names with same phone number comer under same group 1 and Family is "y" for those and for different phone number group is like 1,2,3 etc follows by Family as "N".
People, please remember that you MUST use code tages if you want to preserve white-space in your super duper examples with (for example) columns of data. Otherwise the forum software removes all of your 'extra' spaces. It has been doing this for years, learn to love the Preview button to make sure your example still survives and makes sense when others see it. Please.
-craig
"You can never have too many knives" -- Logan Nine Fingers
i tried by adding new column Group and family in transformer and then tried by using the aggregator stage after transformer but unable to get the result.
If you don't need to preserve the input order, what about using a Sort stage and having it add a group change key? You could then do what you need in stage variables after that.
-craig
"You can never have too many knives" -- Logan Nine Fingers
@Sankar,
I dont think that will work, for the 4th record GROUP should have "3".
In your logic the counter thing is missing, so you have to use one more variable for incrementing the counter.
logic would be:
Sort1- Sort on ph no with Key change col=True--Asc
Sort2- Sort on Ke change col, ph no-asc
Tsfr- Create stgv1 stggroup, Stgv2 Stgfamily, Stgv3 stgprev(Default=1)
stggroup= If keyChange =1 And Stgprev =1 Then 2 Else 1
Stgfamily= If Stggrp =1 Then 'Y' Else 'N'
stgprev= DSLink32.keyChange
map stggroup with group, stgfamily with Family.
-
Sankar
hi,
i tried by using the above logic but its not giving the result expected ,its give group 1 and Family Y for each phone number ,group is not increment for each different number.