Time validation in a csv file

Hi,

Im having a hard time in creating a script with the following conditions below. I have a csv file generated which is updated every 5 mins and it contains a timestamp in it. for example:

time data
00:00 1
00:05 0
00:10 6
00:15 3

however, there is a time that the csv file is not updated this means that a certain line will be skipped.

time data
00:00 1
00:10 7
00:25 8

do any of you guys have an idea on how to validate the data in such a way that if a time is skipped, it will automaticall fill up the missing time?

what i have in mind is that it will return the following:

time data
00:00 1
00:05 0 -turns the missing data into zero value
00:10 7
00:15 0
00:20 0
00:25 8

what i am trying right now is to create a file that contains the correct time incrementation (00:00 / 00:05 / 00:10 .. so on), and then compare the two, however, i dont know where to start...

Thank you again! :slight_smile:

Will the data be guaranteed to always be in spot-on 5 minute intervals unless skipped? A minute less or extra here and there would make it much more difficult to check.

nawk '
function LZ ( X )
{
        if ( length(X) < 2 )
                return "0"X
        else
                return X
}

BEGIN { for (i=0; i<=23; i++ )
          for (j=0; j<=55; j += 5 )
             _[LZ(i),LZ(j)]=0
        }
/:/ { _[substr($1,1,2),substr($1,4,2)]=$2 }

END { for (i=0; i<=23; i++ )
          for (j=0; j<=55; j += 5 )
             print LZ(i)":"LZ(j)" "_[LZ(i),LZ(j)]
        }

'

This uses function LZ (leading zero) to pad the time as required.
BEGIN statement initializes array to 0
Read records with time (containing :slight_smile:
END prints out array using LZ function as well.

actually, the timestamp does not exactly start at 5 mins.
for example:

time data
00:06 8
00:12 2

So what exactly do you want to see?

i.e. Do you still need 5 min increments zeroized?