awk , parse data from stacked columns


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting awk , parse data from stacked columns
# 1  
Old 01-19-2018
Wrench awk , parse data from stacked columns

I am trying to rearrange stacked columns.

Below is an excerpt of my data file:
You can see there are two data columns stacked vertically.
Code:
                                                                                                                                    
ITERATION     Time        Ground
                         Distance

            seconds        feet
--------- ------------ ------------
        0       21.000      985.665
        1       21.150     1002.091
        2       21.300     1018.369
        3       21.450     1034.500
        4       21.600     1050.486
        5       21.750     1066.325
        6       21.900     1082.019                         

            Spoiler
                        Deflection

            seconds      degrees                                          
--------- ------------ ------------   
        0       21.000       70.800 
        1       21.150       70.800
        2       21.300       70.800
        3       21.450       70.800
        4       21.600       70.800 
        5       21.750       70.800 
        6       21.900       70.800

I am using gnuplot to plot the data and require the data columns to be beside each other laterally, not vertically. How can this be achieved with awk or sed?
# 2  
Old 01-19-2018
Code:
awk '
$1 ~ /^[0-9][0-9]*$/ && a[$1] {$1=$1; print $0, a[$1]}
{a[$1]=$2 " " $3}
' datafile

This User Gave Thanks to rdrtx1 For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Need Optimization shell/awk script to aggreagte (sum) for all the columns of Huge data file

Optimization shell/awk script to aggregate (sum) for all the columns of Huge data file File delimiter "|" Need to have Sum of all columns, with column number : aggregation (summation) for each column File not having the header Like below - Column 1 "Total Column 2 : "Total ... ...... (2 Replies)
Discussion started by: kartikirans
2 Replies

2. Shell Programming and Scripting

awk parse result that match data from file

i run command that return this result,example : gigabitethernet2/2/4:NotPresent, gigabitethernet2/1/17:UP, gigabitethernet2/1/10:UP, gigabitethernet2/1/5:UP, gigabitethernet2/1/9:UP, gigabitethernet2/1/36:DOWN, gigabitethernet2/1/33:DOWN, gigabitethernet2/1/8:UP,... (19 Replies)
Discussion started by: wanttolearn1
19 Replies

3. Shell Programming and Scripting

Request: How to Parse dynamic SQL query to pad extra columns to match the fixed number of columns

Hello All, I have a requirement in which i will be given a sql query as input in a file with dynamic number of columns. For example some times i will get 5 columns, some times 8 columns etc up to 20 columns. So my requirement is to generate a output query which will have 20 columns all the... (7 Replies)
Discussion started by: vikas_trl
7 Replies

4. Shell Programming and Scripting

Using awk to parse a file with mixed formats in columns

Greetings I have a file formatted like this: rhino grey weight=1003;height=231;class=heaviest;histology=9,0,0,8 bird white weight=23;height=88;class=light;histology=7,5,1,0,0 turtle green weight=40;height=9;class=light;histology=6,0,2,0... (2 Replies)
Discussion started by: Twinklefingers
2 Replies

5. Shell Programming and Scripting

awk to split and parse unpredictable data

data.txt: CRITICAL: iLash: 97.00%, SqlPlus: 99.00%. Warning/critical thresholds: 95/98% I need to pull only the disknames: iLash and SqlPlus The following command will only pull iLash: echo "CRITICAL: iLash: 97.00%, SqlPlus: 99.00%. Warning/critical thresholds: 95/98%" | awk -F":"... (7 Replies)
Discussion started by: SkySmart
7 Replies

6. Shell Programming and Scripting

awk : Filter a set of data to parse header line and last field of multiple same match.

Hi Experts, I have a data with multiple entry , I want to filter PKG= & the last column "00060110" or "00088150" in the output file: ############################################################################################### PKG= P8SDB :: VGS = vgP8SOra vgP8SDB1 vgP8S001... (5 Replies)
Discussion started by: rveri
5 Replies

7. Shell Programming and Scripting

awk for selecting columns of different data files

Hello friends, How can I use awk commands to obtain selective blocks from different data files. For example file1 a b c d e f g h i file2 1 2 3 4 5 6 7 8 9 output a b 2 3 d e 5 6 g h 8 9 is it possible ? (2 Replies)
Discussion started by: rpf
2 Replies

8. Shell Programming and Scripting

awk based script to find the average of all the columns in a data file

Hi All, I need the modification for the below mentioned code (found in one more post https://www.unix.com/shell-programming-scripting/27161-script-generate-average-values.html) to find the average values for all the columns(but for a specific rows) and print the averages side by side. I have... (4 Replies)
Discussion started by: ks_reddy
4 Replies

9. Shell Programming and Scripting

AWK script to parse a data in a file

Hi Unix gurus.. I have a file which has below data, It has several MQ Queue statistics; QueueName= 'TEST1' CreateDate= '2009-10-30' CreateTime= '13.45.40' QueueType= Predefined QueueDefinitionType= Local QMinDepth= 0 QMaxDepth= 0 QueueName= 'TEST2' CreateDate= '2009-10-30'... (6 Replies)
Discussion started by: dd_psg
6 Replies

10. Shell Programming and Scripting

Awk based script to find the median of all individual columns in a data file

Hi All, I have some data like below. Step1,Param1,Param2,Param3 1,2,3,4 2,3,4,5 2,4,5,6 3,0,1,2 3,0,0,0 3,2,1,3 ........ so on Where I need to find the median(arithmetic) of each column from Param1...to..Param3 for each set of Step1 values. (Sort each specific column, if the... (5 Replies)
Discussion started by: ks_reddy
5 Replies
Login or Register to Ask a Question