Data processing

D

dmoran21

I am working with some files that I need to do some processing with.
Essentially, these files contain rainfall reports from various
automated rain gauges. These reports are given in 15 minute intervals
and the rainfall is a running total throughout the entire file. What I
need to do is process each of the files such that I have one hourly
reading and the precipitation for that hour. So basically, I need to
subtract the amount at the top of the previous hour from the amount
from the top of the current hour. Any suggestions on how this might be
done? I have taken a basic C course, but this seems to be a little
beyond what I know. Below is a sample of the files I am working with.

20060306,1600,29.61
20060306,1615,29.65
20060306,1630,29.69
20060306,1645,29.73
20060306,1700,29.77
20060306,1715,29.81
20060306,1730,29.81
20060306,1745,29.81
20060306,1800,29.81
20060306,1815,29.81
20060306,1830,29.81
20060306,1845,29.81
20060306,1900,29.81
20060306,1915,29.81
20060306,1930,29.81
20060306,1945,29.81
20060306,2000,29.81
20060306,2015,29.81
20060306,2030,29.81
20060306,2045,29.81
20060306,2100,29.81
20060306,2115,29.81
20060306,2130,29.81
20060306,2145,29.81
20060306,2200,29.81
20060306,2215,29.81
20060306,2230,29.81
20060306,2245,29.81
20060306,2300,29.81
20060306,2315,29.81
20060306,2330,29.81
20060306,2345,29.85
20060307,0000,29.89

Thanks.
Dave
 
R

Richard Heathfield

(e-mail address removed) said:
I am working with some files that I need to do some processing with.
Essentially, these files contain rainfall reports from various
automated rain gauges. These reports are given in 15 minute intervals
and the rainfall is a running total throughout the entire file. What I
need to do is process each of the files such that I have one hourly
reading and the precipitation for that hour. So basically, I need to
subtract the amount at the top of the previous hour from the amount
from the top of the current hour. Any suggestions on how this might be
done? I have taken a basic C course, but this seems to be a little
beyond what I know. Below is a sample of the files I am working with.

20060306,1600,29.61
20060306,1615,29.65
20060306,1630,29.69
20060306,1645,29.73
20060306,1700,29.77
20060306,1715,29.81
20060306,1730,29.81
20060306,1745,29.81
20060306,1800,29.81

Define an array of, say, 32 char - call it data[].

Keep reading and discarding lines until data[11] and data[12] are both '0'.
Now convert characters from 14 onwards into a double, using strtod(data +
14, NULL).

That's startval.

***TOP OF MAIN PROCESSING LOOP***

Keep reading and discarding lines until data[11]
and data[12] are both '0'. (Quit if your read fails.)

Now convert characters from 14 onwards into a double,
using strtod(data + 14, NULL).

That's endval.

Display data[0] through [12] (date and time), and endval - startval

Copy endval to startval

Return to top of main processing loop.

Done.
 
D

dmoran21

Richard said:
(e-mail address removed) said:
I am working with some files that I need to do some processing with.
Essentially, these files contain rainfall reports from various
automated rain gauges. These reports are given in 15 minute intervals
and the rainfall is a running total throughout the entire file. What I
need to do is process each of the files such that I have one hourly
reading and the precipitation for that hour. So basically, I need to
subtract the amount at the top of the previous hour from the amount
from the top of the current hour. Any suggestions on how this might be
done? I have taken a basic C course, but this seems to be a little
beyond what I know. Below is a sample of the files I am working with.

20060306,1600,29.61
20060306,1615,29.65
20060306,1630,29.69
20060306,1645,29.73
20060306,1700,29.77
20060306,1715,29.81
20060306,1730,29.81
20060306,1745,29.81
20060306,1800,29.81

Define an array of, say, 32 char - call it data[].

Keep reading and discarding lines until data[11] and data[12] are both '0'.
Now convert characters from 14 onwards into a double, using strtod(data +
14, NULL).

That's startval.

***TOP OF MAIN PROCESSING LOOP***

Keep reading and discarding lines until data[11]
and data[12] are both '0'. (Quit if your read fails.)

Now convert characters from 14 onwards into a double,
using strtod(data + 14, NULL).

That's endval.

Display data[0] through [12] (date and time), and endval - startval

Copy endval to startval

Return to top of main processing loop.

Done.

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at above domain (but drop the www, obviously)

Thanks, this is still a little over my head, but I'll give it a shot.

Dave
 
B

Barry Schwarz

I am working with some files that I need to do some processing with.
Essentially, these files contain rainfall reports from various
automated rain gauges. These reports are given in 15 minute intervals
and the rainfall is a running total throughout the entire file. What I
need to do is process each of the files such that I have one hourly
reading and the precipitation for that hour. So basically, I need to
subtract the amount at the top of the previous hour from the amount
from the top of the current hour. Any suggestions on how this might be
done? I have taken a basic C course, but this seems to be a little
beyond what I know. Below is a sample of the files I am working with.

Read the file till you get to the top of an hour. Save the gauge
value.

Loop until end of file
Read report
If top of hour
Compute and output data for this hour
Save gauge value
Endif
Endloop
20060306,1600,29.61
20060306,1615,29.65
20060306,1630,29.69
20060306,1645,29.73
20060306,1700,29.77
snip


Remove del for email
 
R

Reinhard Skarbal

I am working with some files that I need to do some processing with.
Essentially, these files contain rainfall reports from various
automated rain gauges. These reports are given in 15 minute intervals
and the rainfall is a running total throughout the entire file. What I
need to do is process each of the files such that I have one hourly
reading and the precipitation for that hour. So basically, I need to
subtract the amount at the top of the previous hour from the amount
from the top of the current hour. Any suggestions on how this might be
done? I have taken a basic C course, but this seems to be a little
beyond what I know. Below is a sample of the files I am working with.

20060306,1600,29.61
Thanks.
Dave

Hi Dave

With awk this is done in one line of script :
awk -F"," "{min=substr($2,2,2); if(min=="00"){printf
"%s,%s,%2.2f\n",o1,o2,$3-o3; o1=$1;o2=$2;03=$3}}" inputfile
It's not tested, because ist late in the evening (here in vienna).

Are You working with MS WIN* or with UNIX or LINUX ?
If you need more information ( how to get awk for your PC, ....)
drop me a line and I will answer your question and complete the script.

Regards
Reinhard

Reinhard dot skarbal at aon dot at
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,184
Messages
2,570,978
Members
47,561
Latest member
gjsign

Latest Threads

Top