Sponsored Content
Full Discussion: Impute values within groups
Top Forums Shell Programming and Scripting Impute values within groups Post 302928492 by RudiC on Friday 12th of December 2014 06:24:37 AM
Old 12-12-2014
Well, this again is far from elegant, but try
Code:
awk     'function prlast( ) {
                         for (y in Y)
                                 if (T[y])      {sub (T[y], "", C[LAST])
                                                 delete T[y]
                                                }
                         split (C[LAST], M, "")
                         CNT=0
                         for (t in T) print LAST, t, M[++CNT]M[CNT], "\timputed"
                         delete T
                         LAST=$1
                        }

         NR == 1        {print; Y["T1"]; Y["T2"]; next}
         NR == 2        {LAST=$1}
         $1 != LAST     {prlast()}

         $2 ~ /\*/      {split ($3, M, "")
                         for (i in M) if (!index(C[$1], M[i])) C[$1]=C[$1] M[i]
                         print
                         next
                        }

                        {T[$2]=substr($3,1,1)
                         print
                        }

         END            {prlast()}
        ' SUBSEP="," FS="\t" OFS="\t" file
Group    Type    Value    Serial_Number
Group1    T1    aa    1
Group1    T2    tt    2
Group1    T1*T2    tt    3
Group1    T1*T2    tt    4
Group1    T1*T2    at    5
Group4    T1    aa    1
Group4    T1*T2    gg    3
Group4    T1*T2    aa    4
Group4    T1*T2    ag    5
Group4    T2    gg        imputed
Group5    T1    gg    1
Group5    T1*T2    gg    3
Group5    T1*T2    gt    4
Group5    T1*T2    gg    5
Group5    T2    tt        imputed
Group6    T2    gg    2
Group6    T1*T2    gg    6
Group6    T1*T2    ag    3
Group6    T1*T2    gg    4
Group6    T1*T2    ag    5
Group6    T1    aa        imputed
Group7    T1*T2    ga    7
Group7    T1*T2    gg    8
Group7    T1*T2    ga    9
Group7    T1    gg        imputed
Group7    T2    aa        imputed

As you can see, the "imputed" values are printed at the end of each group. Pipe it through a sort step if that's not acceptable.
This User Gave Thanks to RudiC For This Post:
 

10 More Discussions You Might Find Interesting

1. AIX

Where are my groups

Hello A couple of weeks ago, I added a user to an AIX 5.3 system. I go to add one today, and it appears that when creating a user in smit, I cannot see any groups. No primary groups No Group set No Admin Groups The /etc/group and etc/secuity/group files seem to be intact. I did... (4 Replies)
Discussion started by: mhenryj
4 Replies

2. Shell Programming and Scripting

groups starting with c2?

I have some groups and when i issue a command like groups $LOGNAME it displays in one line rfautosys c2ru cash2 I want to fetch only group starting with c2 but when i grep i am getting full line. Can someone advise on this please as how i can get output as c2ru? (2 Replies)
Discussion started by: gehlnar
2 Replies

3. Solaris

groups

how to create 1000 users in 1 group (0 Replies)
Discussion started by: tirupathi
0 Replies

4. Solaris

groups

1 user in member of 4 groups find file permissions and default group (1 Reply)
Discussion started by: tirupathi
1 Replies

5. Shell Programming and Scripting

Remove matched values and their related groups

For each value in file1 it has to check in file2 and file3. If value matched it has to delete that value and related group value in file2 and file3. In this example it takes A , deletes A and take related group value 1 and deletes E-1,then checks in file3 and deletes K-1.After that it takes D... (7 Replies)
Discussion started by: kanagaraj
7 Replies

6. HP-UX

Groups access

Hi all, Can someone tell me how I can get around this problem. Basically I use the HP-UX OS and I work with 2 top level directories. /z/group1 /z/group2 these 2 dirs are managed where group1 can only be access by one set of users and group2 another. This is managed by adding the 2... (3 Replies)
Discussion started by: cyberfrog
3 Replies

7. Shell Programming and Scripting

Groups in Unix ???

What is Primary group and Secondary Group in Unix.? (1 Reply)
Discussion started by: gwgreen1
1 Replies

8. UNIX for Dummies Questions & Answers

Groups

Must I be in a group? I am using Ubuntu and am the only user on my PC. I know how to change groups but do not see a way to not be in a group. Any help would be appreciated. (2 Replies)
Discussion started by: nthepines
2 Replies

9. Shell Programming and Scripting

Print values within groups of lines with awk

Hello to all, I'm trying to print the value corresponding to the words A, B, C, D, E. These words could appear sometimes and sometimes not inside each group of lines. Each group of lines begins with "ZYX". My issue with current code is that should print values for 3 groups and only is... (6 Replies)
Discussion started by: Ophiuchus
6 Replies

10. Solaris

Groups is not visible

OS : SunOS 5.8 I am trying to add a user ad3059 to the following groups, A B C D ( four groups A,B,C,D) When i use usermod command and add the user to the above groups, and go to > groups ad3059 other C D It doesnt show A and B groups and shows it as other.Please advice on how... (13 Replies)
Discussion started by: Revathi2089
13 Replies
PAPS(1) 						      General Commands Manual							   PAPS(1)

NAME
paps - UTF-8 to PostScript converter using Pango SYNOPSIS
paps [options] files... DESCRIPTION
paps reads a UTF-8 encoded file and generates a PostScript language rendering of the file. The rendering is done by creating outline curves through the pango ft2 backend. OPTIONS
These programs follow the usual GNU command line syntax, with long options starting with two dashes (`-'). A summary of options is included below. --landscape Landscape output. Default is portrait. --columns=cl Number of columns output. Default is 1. --font=desc Set the font description. Default is Monospace 12. --rtl Do rtl layout. --paper ps Choose paper size. Known paper sizes are legal, letter, a4. Default is A4. --bottom-margin=bm Set bottom margin in postscript points (1/72 inch). Default is 36. --top-margin=tm Set top margin. Default is 36. --left-margin=lm Set left margin. Default is 36. --right-margin=rm Set right margin. Default is 36. --help Show summary of options. --header Draw page header for each page. --markup Interpret the text as pango markup. --encoding=ENCODING Assume the documentation encoding is ENCODING. --lpi Set the lines per inch. This determines the line spacing. --cpi Set the characters per inch. This is an alternative method of specifying the font size. --stretch-chars Indicates that characters should be stretched in the y-direction to fill up their vertical space. This is similar to the texttops behaviour. AUTHOR
paps was written by Dov Grobgeld <dov.grobgeld@gmail.com>. This manual page was written by Lior Kaplan <kaplan@debian.org>, for the Debian project (but may be used by others). April 17, 2006 PAPS(1)
All times are GMT -4. The time now is 12:55 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy