Extract Velocity Data (Loc, Time, Velocity)


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Extract Velocity Data (Loc, Time, Velocity)
# 8  
Old 09-29-2011
post your original file contents
# 9  
Old 09-29-2011
some awk's are picky....:
Code:
nawk '/^HANDVEL/ {hand=$2}/^[0-9]/ {for(i=1; i<=NF;i=i+2) print hand, $i, $(i+1)}' myFile

# 10  
Old 10-05-2011
I revisted the code and try few things on the syntax. I got this to work with the following syntax:

Code:
awk '/HANDVEL/ (a=$2), /^[0-9]/ {for(i=1;i<=NF;i+=2)print a,$i,$(i+1)}' input

However it captured the ff: The Handel value is the same throughout althought it changes on the next HANDVEL sequence.
Any suggestions? Thanks

Code:
20096 HANDVEL 20096
0096 
20096 4 9165
20096 140 10249
20096 268 11430
20096 372 12265
20096 556 13573
20096 652 14152
20096 780 14602
20096 924 15095
20096 1064 15395
20096 1172 15502
20096 1336 15545
20096 1512 15459
20096 1756 15738
20096 1860 16059
20096 2176 17109
20096 2532 18160
20096 2928 18760
20096 5996 22188
20096 HANDVEL 20192
0096 
20096 16 9222
20096 176 10701
20096 264 11430

Moderator's Comments:
Mod Comment
Please use code tags when posting data and code samples!


---------- Post updated at 08:58 AM ---------- Previous update was at 08:18 AM ----------

I have cleaned-up my original input to as ffs:

Code:
HANDVEL 20096 
4 9165 140 10249 268 11430 372 12265
556 13573 652 14152 780 14602 924 15095
1064 15395 1172 15502 1336 15545 1512 15459
1756 15738 1860 16059 2176 17109 2532 18160
2928 18760 5996 22188
HANDVEL 20192 
16 9222 176 10701 264 11430 368 12158
444 12737 548 13530 644 14152 784 14666
932 15159 1064 15459 1168 15545 1320 15502
1492 15416 1756 15738 1852 16016 2192 17045
2524 18138 2884 18695 5996 22188
HANDVEL 20288 
20 9243 160 10658 204 11365 336 12651
444 13444 560 13937 652 14237 776 14537
924 15159 1052 15438 1168 15523 1316 15309
1452 15137 1736 15416 1824 15673 2164 16852
2516 17967 2864 18545 5996 22188


Last edited by rtsiahaan; 10-05-2011 at 11:01 AM.. Reason: once again - please use code tags!
# 11  
Old 10-05-2011
what's wrong with the original solution?
I do follow the 'ff' explanation/notion....

your posted code is NOT what was suggested originally:
Code:
nawk '/^HANDVEL/ {hand=$2}/^[0-9]/ {for(i=1; i<=NF;i=i+2) print hand, $i, $(i+1)}'


Last edited by vgersh99; 10-05-2011 at 04:18 PM..
# 12  
Old 10-05-2011
Thank you for your comment.
1. My Linux does not have nawk so I was trying to run awk. Typed "which nawk" returned with ... no nawk in......
2. With awk, the posted original code did not work. There were no return and just hang. Have to ctrl c to clear it.
3. Out of curosity I modified at the syntax as I posted and that runs BUT incorrect output.
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Programming

Find gaps in time data and replace missing time value and column 2 value by interpolation in awk

Dear all, I am kindly seeking assistance on the following issue. I am working with data that is sampled every 0.05 hours (that is 3 minutes intervals) here is a sample data from the file 5.00000 15.5030 5.05000 15.6680 5.10000 16.0100 5.15000 16.3450 5.20000 16.7120 5.25000... (4 Replies)
Discussion started by: malandisa
4 Replies

2. Shell Programming and Scripting

Extract data from log file within specified time

So, we have a script, that is supposed to have a couple of functions like showing number of failed connections, recieved bytes per IP-address, and so on. We are supposed to be able to limit the number of results to either 0-24 hours or X days back from the last data in the log file. Everything... (3 Replies)
Discussion started by: Plumpen
3 Replies

3. Shell Programming and Scripting

Extract data from log file in specified range of time

I was searching for parsing a log file and found what I need in this link http://stackoverflow.com/questions/7575267/extract-data-from-log-file-in-specified-range-of-time But the most useful answer (posted by @Kent): # this variable you could customize, important is convert to seconds. # e.g... (2 Replies)
Discussion started by: kingk110
2 Replies

4. Shell Programming and Scripting

Extract specific data content from a long list of data

My input: Data name: ABC001 Data length: 1000 Detail info Data Direction Start_time End_time Length 1 forward 10 100 90 1 forward 15 200 185 2 reverse 50 500 450 Data name: XFG110 Data length: 100 Detail info Data Direction Start_time End_time Length 1 forward 50 100 50 ... (11 Replies)
Discussion started by: patrick87
11 Replies

5. Shell Programming and Scripting

Extract data based on match against one column data from a long list data

My input file: data_5 Ali 422 2.00E-45 102/253 140/253 24 data_3 Abu 202 60.00E-45 12/23 140/23 28 data_1 Ahmad 256 7.00E-45 120/235 140/235 22 data_4 Aman 365 8.00E-45 15/65 140/65 20 data_10 Jones 869 9.00E-45 65/253 140/253 18... (12 Replies)
Discussion started by: patrick87
12 Replies

6. Shell Programming and Scripting

extract data from a data matrix with filter criteria

Here is what old matrix look like, IDs X1 X2 Y1 Y2 10914061 -0.364613333 -0.362922333 0.001691 -0.450094667 10855062 0.845956333 0.860396667 0.014440333 1.483899333... (7 Replies)
Discussion started by: ssshen
7 Replies

7. Shell Programming and Scripting

How to get data between the start time and end time?

Hi, Can anyone help me how can I get the line that between the start time and end time. file1.txt 15/03/2009 20:45:03 Request: - Data of this line 15/03/2009 20:45:12 Response: - Data of this line 15/03/2009 22:10:40 Request: - Data of this line 15/03/2009 22:10:42 Response: - Data of... (1 Reply)
Discussion started by: tanit
1 Replies

8. Shell Programming and Scripting

To extract data of a perticular interval (date-time wise)

I want a shell script which extract data from a log file which contains date and time-wise data and i need the data for a perticular interval of time...what can i do??? (3 Replies)
Discussion started by: abhishek27
3 Replies

9. Programming

Counting LOC in C

Hi Do you know where I can find any utility that counts lines of code in a C program, accurately? The ones that count the semicolons does not give correct results. Thanx Andonis Matsakas (1 Reply)
Discussion started by: amatsaka
1 Replies
Login or Register to Ask a Question