[Tutor] Filling in Missing Data from Txt Files - Resubmitted

Alan Gauld alan.gauld at btinternet.com
Tue Jan 11 19:00:23 CET 2011


"Benson, Randall" <Randall.Benson at iberdrolaren.com> wrote

> hour as shown below.  In the sample below there is no data for hours
> 1000, 1100, 1200 and 1300.  For these missing data rows I need to 
> insert
> the correct date, time and -9999 for the other missing data columns
> (columns 2-6).

> 080618 0950  5.10  7.40 224.0  -3.54  -3.67
> 080618 1000  4.62  7.00 227.0  -3.38  -3.15
> 080618 1410  5.19  7.30 232.0  -4.09  -3.20

OK, In pseudo code it could be something like

prev_datetime = get startdate
for line in file:
     extract datetime from line
     while datetime - prev_datetime > 10 minutes # missing data
            write dummy data
            prev_datetime += 10 minutes
     prev_datetime = datetime
     write data


Does that help?


-- 
Alan Gauld
Author of the Learn to Program web site
http://www.alan-g.me.uk/




More information about the Tutor mailing list