Released Script:
This is now a released script.
http://cumulus.tnetweather.com/projects.phpdayfile
Code: Select all
v0.11 2010-02-12 Updated windrun units
v0.10 2010-02-10 Initial Beta Release
This morning while waiting for access to a server at work, I took a quick look at the dayfile.txt
Seemed like it would be easy to parse and display on the fly without a database, JavaScript etc.. just using PHP.
So I...
o Setup an FTP process on SysBackSE to upload the file once a day at 12 min after Midnight. This actually took most of the time since I've not setup a new job in this for sometime. Seems like they have changed the interface to make it less intuitive over time.
o Wrote a crude script to read the dayfile.txt and store it into an array
o Setup a simple loop looking for the day and year I want to display
o Output the data in a table with CSS tags so that it can be formatted however it needs to be.
Goals were:
o Fast, easy to setup.
o No database needed
o No JavaScript needed
o Try to keep data 700px or less in width so that it fits better on my type of pages.
The dayfile.txt uploaded today was about 48kb in size so parsing it is very fast. Other than doing a date conversion (ISO Date format) so that I could reorder the records if needed, nothing else was really done with the data other than suck it into an Array using file and preg_split.
To keep the width smaller, I didn't bother outputting the times of things like time of max temp etc.. Didn't really have much desire to see that anyway. It is of course there if needed.
I didn't bother doing any sorts on columns other than keep the days in order.
Rough output of the script is:
http://cumulus.tnetweather.com/test/dayfile.php
Used inside a website it looks cleaner...
http://cumulus.tnetweather.com/trends/monthly
Eventually over the years, the file will get larger as it never breaks up into year files. But since it is uploaded only once a day, it would be easy if necessary to just split it up into separate files when parsed. Right now, it is just reading the file, not writing anything.
Needs some tweaking to know what formats are being used, but that info could be obtained from the realtime.txt file itself. Also would need a way to get the file to the server. Cumulus doesn't have such a once a day feature.
Could uses Daz's tool if you don't already have a way to upload.
I just added it to one of my SysBackSE which I already have for other misc weather related stuff including workstation backups.
Oh... options.
If you call the raw script with no options, it takes today's year and month as the data set to use. Using m=XX changes the month, and y=XXXX changes the year.
So if you wanted to see Nov 2009
http://cumulus.tnetweather.com/test/day ... =11&y=2009
As par usual, spent more time documenting that actually using the script.