Home » Infrastructure » Linux » Awk counter help
Awk counter help [message #281567] Sun, 18 November 2007 07:23 Go to next message
tteklem
Messages: 2
Registered: November 2007
Junior Member
I have a large annual data with a time stamps that increment by 0.002 minutes (ie 1.002 ...365.998 ). Some data is missing in my data and the time stamp is not regularly spaced (e.g 1.002, 1.006 skipping 1.004). the desired output is 1st generate artificial data in column 1 as a time stamp 1.00 to 365.998 regularly spaced with a step of 0.002. Then sort my data to this column puting the data stamp but leaving the values empty when data is missing so that my time series data is equally spaced with empty lines when data point is missing. I have the following awk code to do the job but this will only count by 1.
awk '{a[$1]=$0}END{for(i=1;i<=366;++i) print ((i in a)?a[i]:i)}' /path/to/input
I am not sure how to make it count by 0.002 instead.
I appreciate any tips!
Re: Awk counter help [message #281586 is a reply to message #281567] Sun, 18 November 2007 08:55 Go to previous messageGo to next message
Michel Cadot
Messages: 58954
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
Maybe someone can help you but this is an Oracle forum so you should have a better chance to get an answer on a Unix/Linux one.

Regards
Michel
Re: Awk counter help [message #281599 is a reply to message #281586] Sun, 18 November 2007 11:40 Go to previous messageGo to next message
tteklem
Messages: 2
Registered: November 2007
Junior Member
Thanks Michel
Re: Awk counter help [message #283556 is a reply to message #281599] Tue, 27 November 2007 08:08 Go to previous message
virtualmorrigan
Messages: 7
Registered: November 2007
Junior Member
I don't quite get what you want to do, but does

awk '{a[$1]=$0}END{for(i=1;i<=366;i=i+0.002) print ((i in a)?a[i]:i)}'
do what you want?

Previous Topic: Java Run Time
Next Topic: Oracle Database 10g Release 2 on Linux x86
Goto Forum:
  


Current Time: Mon Sep 01 20:03:54 CDT 2014

Total time taken to generate the page: 0.09310 seconds