|
AWK program with array variable
Hi,
I made a small awk program just to test array variables.
I couldn't find anything wrong with it.
But it doesn't give out valid numbers.( just 0.00 )
Do you see any problem that I didn't see?
Thanks in advance!
Here is the program:
##################################
BEGIN {
FS = ","
}
{
job = $2
station = $3
time_period = substr($6,1,3)
wait= $11
if (station > 0) {
while ( y <=24 ) {
++y
if ( time_period == y ) {
hour[y] += wait
++i[y]
}
}
}
}
END {
y = 0
while ( z <= 24 ) {
++z
++y
if ( i[y] > 0 ) {
AVG[z]=hour[y]/i[y]
printf("%9.2f\n",AVG[z])
}
}
}
###################################
Here is one row of my data file:
17.11.2004,5189400,222,12538476808, 215, 23:51:01, 23:51:14, 23:51:27, 13, 0, 13, d, 1, 0, 20718, (253)847-6, 1303, -1, 23:51:04, 23:51:04, 0, 23, 3, 1, 2, 0, respo, DEL
Last edited by whatisthis; 05-10-2005 at 09:29 AM..
Reason: typo
|