[Tutor] Filling in Missing Data from Txt Files - Resubmitted
ALAN GAULD
alan.gauld at btinternet.com
Tue Jan 11 22:34:50 CET 2011
forwarding to group.
Please use Reply-All when responding to the group.
Alan Gauld
Author of the Learn To Program website
http://www.alan-g.me.uk/
----- Original Message ----
> From: "Benson, Randall" <Randall.Benson at iberdrolaren.com>
> To: Alan Gauld <alan.gauld at btinternet.com>
> Sent: Tuesday, 11 January, 2011 19:47:21
> Subject: RE: [Tutor] Filling in Missing Data from Txt Files - Resubmitted
>
> Hi Alan,
>
> I'm kind of new to Python but I think I understand your proposed code
> below. However, I only need to write missing data to the output file if
> there is no 10 min period of data available during any given hour. In
> other words, write to the output file missing data when an entire hour
> or 6 data records are missing. Otherwise, I use any and all available
> 10 min periods to calculate the average for that hour.
>
> I've thought of reading all the data in first looking at the date and
> time columns and then write -9999 to an output file with the missing
> 10-min periods and the good data and then go back through the input file
> to make the hourly averages of the 10-min data now with missing data
> values and good data. Would that approach work? If so, how would you
> set up the loop structure for finding the missing hours and then
> inserting -9999's?
>
>
>
>
> Randall P. Benson, PhD
> Global Technical Division/Energy Resources
> O: 503-796-7129
> M: 971-227-2477
>
>
> -----Original Message-----
> From: tutor-bounces+randall.benson=iberdrolaren.com at python.org
> [mailto:tutor-bounces+randall.benson=iberdrolaren.com at python.org] On
> Behalf Of Alan Gauld
> Sent: Tuesday, January 11, 2011 10:00 AM
> To: tutor at python.org
> Subject: Re: [Tutor] Filling in Missing Data from Txt Files -
> Resubmitted
>
>
> "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/
>
>
> _______________________________________________
> Tutor maillist - Tutor at python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor
>
> Please be advised that email addresses for Iberdrola Renewables personnel have
>changed to first.last at iberdrolaREN.com effective Aug. 16, 2010. Please make a
>note. Thank you.
>
> This message is intended for the exclusive attention of the recipient(s)
>indicated. Any information contained herein is strictly confidential and
>privileged. If you are not the intended recipient, please notify us by return
>e-mail and delete this message from your computer system. Any unauthorized use,
>reproduction, alteration, filing or sending of this message and/or any attached
>files may lead to legal action being taken against the party(ies) responsible
>for said unauthorized use. Any opinion expressed herein is solely that of the
>author(s) and does not necessarily represent the opinion of the Company. The
>sender does not guarantee the integrity, speed or safety of this message, and
>does not accept responsibility for any possible damage arising from the
>interception, incorporation of viruses, or any other damage as a result of
>manipulation.
>
>
>
More information about the Tutor
mailing list