Arrange same data in same column ....


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Arrange same data in same column ....
# 1  
Old 04-02-2012
Bug Arrange same data in same column ....

I have vary complex issue in unix...i want copy same data in same column...

My Input...

Code:
Object                     SpchAccate       hAes     hCCS     SDop         Sroontb         NoRabEt      SRbuc
ran=C515D (Mod=15)                  0        100     98.1      1.9             0.6              73        100
ran=C515E (Mod=15)                  0        100      100        0               0              13        100
ran=C515F (Mod=15)                  0        100      100        0               0               1        100
ran=C515T (Mod=15)               -1.0      101.0     99.7      1.3             1.2             170        100
ran=C515U (Mod=15)                  0        100      100        0               0              19        100
ran=C515V (Mod=15)                  0        100      100        0               0              51        100
ran=C916D (Mod=3)                   0        100      100        0               0              63        100
ran=C916E (Mod=3)                   0        100      100        0               0              44        100
ran=C916F (Mod=3)                 N/A        N/A      N/A        0               0               1        100
Object                       CllFop      DCHMinpp        FACHrop 
ran=C0515D (Mod=15)             1.3          20.2           43.6 
ran=C0515E (Mod=15)               0           N/A            N/A 
ran=C0515F (Mod=15)               0           N/A            N/A 
ran=C0515T (Mod=15)             0.9          24.3           49.9 
ran=C0515U (Mod=15)               0           N/A            N/A 
ran=C0515V (Mod=15)             0.5          20.6          107.2 
ran=C0916D (Mod=3)              1.2          22.9           57.1 
ran=C0916E (Mod=3)              0.6          39.5          105.8 
ran=C0916F (Mod=3)             12.5           0.6            9.8 
Object           Counter  18:45  19:00  19:15
ran=C0515D (Mod=15)    U -105.4 -105.4 -105.5
ran=C0515E (Mod=15)    U -105.4 -105.5 -105.5
ran=C0515F (Mod=15)    U -105.7 -105.7 -105.7
ran=C0515T (Mod=15)    U -100.4 -100.8 -100.7
ran=C0515U (Mod=15)    U -102.8 -102.3 -102.6
ran=C0515V (Mod=15)    U -103.0 -102.3 -102.9
ran=C0916D (Mod=3)     U -105.8 -105.9 -106.0
ran=C0916E (Mod=3)     U -105.4 -105.5 -105.3
ran=C0916F (Mod=3)     U -106.3 -106.3 -106.4

My Output


Code:
Object                     SpchAccate       hAes     hCCS     SDop         Sroontb         NoRabEt      SRbuc	Object                       CllFop      DCHMinpp        FACHrop 	Object           Counter  18:45  19:00  19:15
ran=C515D (Mod=15)                  0        100     98.1      1.9             0.6              73        100	ran=C0515D (Mod=15)             1.3          20.2           43.6 	ran=C0515D (Mod=15)    U -105.4 -105.4 -105.5
ran=C515E (Mod=15)                  0        100      100        0               0              13        100	ran=C0515E (Mod=15)               0           N/A            N/A 	ran=C0515E (Mod=15)    U -105.4 -105.5 -105.5
ran=C515F (Mod=15)                  0        100      100        0               0               1        100	ran=C0515F (Mod=15)               0           N/A            N/A 	ran=C0515F (Mod=15)    U -105.7 -105.7 -105.7
ran=C515T (Mod=15)               -1.0      101.0     99.7      1.3             1.2             170        100	ran=C0515T (Mod=15)             0.9          24.3           49.9 	ran=C0515T (Mod=15)    U -100.4 -100.8 -100.7
ran=C515U (Mod=15)                  0        100      100        0               0              19        100	ran=C0515U (Mod=15)               0           N/A            N/A 	ran=C0515U (Mod=15)    U -102.8 -102.3 -102.6
ran=C515V (Mod=15)                  0        100      100        0               0              51        100	ran=C0515V (Mod=15)             0.5          20.6          107.2 	ran=C0515V (Mod=15)    U -103.0 -102.3 -102.9
ran=C916D (Mod=3)                   0        100      100        0               0              63        100	ran=C0916D (Mod=3)              1.2          22.9           57.1 	ran=C0916D (Mod=3)     U -105.8 -105.9 -106.0
ran=C916E (Mod=3)                   0        100      100        0               0              44        100	ran=C0916E (Mod=3)              0.6          39.5          105.8 	ran=C0916E (Mod=3)     U -105.4 -105.5 -105.3
ran=C916F (Mod=3)                 N/A        N/A      N/A        0               0               1        100	ran=C0916F (Mod=3)             12.5           0.6            9.8 	ran=C0916F (Mod=3)     U -106.3 -106.3 -106.4

# 2  
Old 04-02-2012
Your output doesn't match your input. Where'd you get the time-columns for C515D, etc?
# 3  
Old 04-02-2012
Bug

Sorry It my mistake...

Input:


Code:
Object                     SpchAccate       hAes     hCCS     SDop         Sroontb         NoRabEt      SRbuc
ran=C0515D (Mod=15)                  0        100     98.1      1.9             0.6              73        100
ran=C0515E (Mod=15)                  0        100      100        0               0              13        100
ran=C0515F (Mod=15)                  0        100      100        0               0               1        100
ran=C0515T (Mod=15)               -1.0      101.0     99.7      1.3             1.2             170        100
ran=C0515U (Mod=15)                  0        100      100        0               0              19        100
ran=C0515V (Mod=15)                  0        100      100        0               0              51        100
ran=C0916D (Mod=3)                   0        100      100        0               0              63        100
ran=C0916E (Mod=3)                   0        100      100        0               0              44        100
ran=C0916F (Mod=3)                 N/A        N/A      N/A        0               0               1        100
Object                       CllFop      DCHMinpp        FACHrop 
ran=C0515D (Mod=15)             1.3          20.2           43.6 
ran=C0515E (Mod=15)               0           N/A            N/A 
ran=C0515F (Mod=15)               0           N/A            N/A 
ran=C0515T (Mod=15)             0.9          24.3           49.9 
ran=C0515U (Mod=15)               0           N/A            N/A 
ran=C0515V (Mod=15)             0.5          20.6          107.2 
ran=C0916D (Mod=3)              1.2          22.9           57.1 
ran=C0916E (Mod=3)              0.6          39.5          105.8 
ran=C0916F (Mod=3)             12.5           0.6            9.8 
Object           Counter  18:45  19:00  19:15
ran=C0515D (Mod=15)    U -105.4 -105.4 -105.5
ran=C0515E (Mod=15)    U -105.4 -105.5 -105.5
ran=C0515F (Mod=15)    U -105.7 -105.7 -105.7
ran=C0515T (Mod=15)    U -100.4 -100.8 -100.7
ran=C0515U (Mod=15)    U -102.8 -102.3 -102.6
ran=C0515V (Mod=15)    U -103.0 -102.3 -102.9
ran=C0916D (Mod=3)     U -105.8 -105.9 -106.0
ran=C0916E (Mod=3)     U -105.4 -105.5 -105.3
ran=C0916F (Mod=3)     U -106.3 -106.3 -106.4


Output:
Code:
Object                     SpchAccate       hAes     hCCS     SDop         Sroontb         NoRabEt      SRbuc	Object                       CllFop      DCHMinpp        FACHrop 	Object           Counter  18:45  19:00  19:15
ran=C0515D (Mod=15)                  0        100     98.1      1.9             0.6              73        100	ran=C0515D (Mod=15)             1.3          20.2           43.6 	ran=C0515D (Mod=15)    U -105.4 -105.4 -105.5
ran=C0515E (Mod=15)                  0        100      100        0               0              13        100	ran=C0515E (Mod=15)               0           N/A            N/A 	ran=C0515E (Mod=15)    U -105.4 -105.5 -105.5
ran=C0515F (Mod=15)                  0        100      100        0               0               1        100	ran=C0515F (Mod=15)               0           N/A            N/A 	ran=C0515F (Mod=15)    U -105.7 -105.7 -105.7
ran=C0515T (Mod=15)               -1.0      101.0     99.7      1.3             1.2             170        100	ran=C0515T (Mod=15)             0.9          24.3           49.9 	ran=C0515T (Mod=15)    U -100.4 -100.8 -100.7
ran=C0515U (Mod=15)                  0        100      100        0               0              19        100	ran=C0515U (Mod=15)               0           N/A            N/A 	ran=C0515U (Mod=15)    U -102.8 -102.3 -102.6
ran=C0515V (Mod=15)                  0        100      100        0               0              51        100	ran=C0515V (Mod=15)             0.5          20.6          107.2 	ran=C0515V (Mod=15)    U -103.0 -102.3 -102.9
ran=C0916D (Mod=3)                   0        100      100        0               0              63        100	ran=C0916D (Mod=3)              1.2          22.9           57.1 	ran=C0916D (Mod=3)     U -105.8 -105.9 -106.0
ran=C0916E (Mod=3)                   0        100      100        0               0              44        100	ran=C0916E (Mod=3)              0.6          39.5          105.8 	ran=C0916E (Mod=3)     U -105.4 -105.5 -105.3
ran=C0916F (Mod=3)                 N/A        N/A      N/A        0               0               1        100	ran=C0916F (Mod=3)             12.5           0.6            9.8 	ran=C0916F (Mod=3)     U -106.3 -106.3 -106.4

# 4  
Old 04-02-2012
Code:
sed -n '1,10p' infile > file1
sed -n '11,20p' infile > file2
sed -n '21,30p' infile > file3
paste file1 file2 file3

or
Code:
paste < <(sed -n '1,10p' infile) <(sed -n '11,20p' infile) <(sed -n '21,30p' infile)

but, this doesn't work properly.
# 5  
Old 04-03-2012
Bug

Thanks ....but the row in not fixed......right now its three set but it will be change ......
# 6  
Old 04-03-2012
I can assemble the data, but getting the columns to line up is being very difficult...
# 7  
Old 04-03-2012
Assuming tab-separated data is useful to you:

Code:
$ cat assemble.awk

/^Object/ {
        for(X in F) delete F[X]

        for(N=1; N<=NF; N++)
        {
                if((!O[$N]) || ($N == "Object"))
                {
                        O[$N]=++L;
                        O[L]=$N;
                }

                if((!SIZE[$N]) || (SIZE[$N] < length($N))) SIZE[$N]=length($N);

                F[N+1]=O[O[$N]]
        }
        next
}

{
        OBJ[$1,$2]=1;   # Update list of objects

        for(N=2; N<=NF; N++)
        {
                if(F[N] == "Object")    COL=$1 " " $2;
                else                    COL=$N

                D[$1,$2,F[N]]=COL
                if((!SIZE[F[N]]) || (SIZE[F[N]] < length(COL)))
                        SIZE[F[N]]=length(COL);
        }
}

END {
        PFIX=""
        for(N=1; N<=L; N++)
        {
                printf("%s", PFIX O[N]);
                PFIX="\t"
        }

        printf("\n");

        for(X in OBJ)
        {
                split(X, A, SUBSEP);

                PFIX=""
                for(N=1; N<=L; N++)
                {
                        printf("%s", PFIX D[A[1],A[2],O[N]]);
                        PFIX="\t"
                }

                printf("\n");
        }
}

$ awk -f assemble.awk data

Object  SpchAccate      hAes    hCCS    SDop    Sroontb NoRabEt SRbuc   Object  CllFop  DCHMinpp        FACHrop Object  Counter 18:45   19:00   19:15
ran=C0515U (Mod=15)     0       100     100     0       0       19      100     ran=C0515U (Mod=15)     0       N/A     N/A     ran=C0515U (Mod=15)     U       -102.8  -102.3  -102.6
ran=C0916F (Mod=3)      N/A     N/A     N/A     0       0       1       100     ran=C0916F (Mod=3)      12.5    0.6     9.8     ran=C0916F (Mod=3)      U       -106.3  -106.3  -106.4
ran=C0515T (Mod=15)     -1.0    101.0   99.7    1.3     1.2     170     100     ran=C0515T (Mod=15)     0.9     24.3    49.9    ran=C0515T (Mod=15)     U       -100.4  -100.8  -100.7
ran=C0916E (Mod=3)      0       100     100     0       0       44      100     ran=C0916E (Mod=3)      0.6     39.5    105.8   ran=C0916E (Mod=3)      U       -105.4  -105.5  -105.3
ran=C0916D (Mod=3)      0       100     100     0       0       63      100     ran=C0916D (Mod=3)      1.2     22.9    57.1    ran=C0916D (Mod=3)      U       -105.8  -105.9  -106.0
ran=C0515F (Mod=15)     0       100     100     0       0       1       100     ran=C0515F (Mod=15)     0       N/A     N/A     ran=C0515F (Mod=15)     U       -105.7  -105.7  -105.7
ran=C0515E (Mod=15)     0       100     100     0       0       13      100     ran=C0515E (Mod=15)     0       N/A     N/A     ran=C0515E (Mod=15)     U       -105.4  -105.5  -105.5
ran=C0515D (Mod=15)     0       100     98.1    1.9     0.6     73      100     ran=C0515D (Mod=15)     1.3     20.2    43.6    ran=C0515D (Mod=15)     U       -105.4  -105.4  -105.5
ran=C0515V (Mod=15)     0       100     100     0       0       51      100     ran=C0515V (Mod=15)     0.5     20.6    107.2   ran=C0515V (Mod=15)     U       -103.0  -102.3  -102.9

$

The "ran=C0515V (Mod=15)" are separated by space, so are the first column, not the first two columns.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Arrange data in table

Hello All, I have following data into my file named record. Name City phone number email Jhon Newyork 123456987 jhon@gmail.com Maria Texas 569865612 Maria_Sweet@rediffmail.com Chan Durben NA Chan123@gmail.com The output should be in straight columns.. There should not be any... (1 Reply)
Discussion started by: Nakul_sh
1 Replies

2. Shell Programming and Scripting

Arrange data in table

Hello All, I have following data into my file named record. Name City phone number email Jhon Newyork 123456987 jhon@gmail.com Maria Texas 569865612 Maria_Sweet@rediffmail.com Chan Durben NA Chan123@gmail.com |---------------------------------------------------------------| |Name ... (2 Replies)
Discussion started by: Nakul_sh
2 Replies

3. Shell Programming and Scripting

Arrange values of a column in row

HI, I need to arrange values of a colum in row. e.g. input file : Alpha<>123 AAAA<>6754 Beta<>456 BBBB<>63784 CCC<>783 Gama<>789 Alpha<>555 AAAA<>6754 BBBB<>63784 Beta<>666 CCC<>783 Gama<>888 (9 Replies)
Discussion started by: The_Archer
9 Replies

4. Shell Programming and Scripting

Arrange / format data using awk

Input 217:fngadi4osa:fngadi4osa:M 217:415744:N/A 227:fngadi4osa:fngadi4osa: M 227:51200:N/A 228:fngadi4osa:fngadi4osa: M 228:102400:N/A 65:sapgt04:sapgt04: M 65:104448:N/A 228:fngadi4osa:fngadi4oma: M 228:102400:N/A Output 217:fngadi4osa:fngadi4osa:M 217:415744:N/A... (3 Replies)
Discussion started by: greycells
3 Replies

5. Shell Programming and Scripting

arrange merged data using sed

hi, i used paste file1.txt file2.txt > file3.txt to merge 2 columns from file1 and 4 columns from file2. file1 scaffold_217 scaffold_217 file2 CHRSM N scaffold_217.pf scaffold_217.fsa the result is as follows:- scaffold_217 scaffold_217 CHRSM ... (6 Replies)
Discussion started by: redse171
6 Replies

6. Shell Programming and Scripting

Re-arrange column

10.142.7.155 - - www.abc.com 404 - I have many columns which is tab delimited file, I have to re-arrange this to a particular column and also add "-" to 3rd column and 6th column. 10.142.7.155 - - - www.abc.com - 404 - (4 Replies)
Discussion started by: sandy1028
4 Replies

7. UNIX for Dummies Questions & Answers

Extract Data and arrange it based on timelines

Hi Im trying to extract a specific pattern of data from a log file and store it in a other file, Im executing the below command in various files and storing it in a single file. I data that Im storing needs to be arranged based on a date and timestamp. Please assist, how to achieve this. Thanks... (1 Reply)
Discussion started by: vr3w3c9
1 Replies

8. UNIX for Dummies Questions & Answers

Arrange data

I have a following data: 100 200 300 400 I want the data to be arranged: 100 200 300 400 What is the best way to do this? Thanks! (5 Replies)
Discussion started by: bobo
5 Replies

9. Shell Programming and Scripting

arrange data tools

Which is the best command(s) to arrange data of a file? This is my example input file: Tom ------ apples: 5 oranges: 7 pears: 10 apples: 2 oranges: 8 Jack ------ apples: 3 pears: 10 Lucy ------ oranges: 1 pears: 8 peaches: 9 Tom ------ peaches: 1 Jack ------ (1 Reply)
Discussion started by: csecnarf
1 Replies

10. Shell Programming and Scripting

re arrange data

Any idea in awk or sed? $cat file a b c 2 4 5 6 output: a b c 2 4 5 6 (3 Replies)
Discussion started by: kenshinhimura
3 Replies
Login or Register to Ask a Question