PHP Extraction of WD Avg/Ext HTM Files

The source code for the extraction PHP code that I used to read an existing Avg/Ext htm file (i.e. December2007.htm), is now available.

Basically, it reads the Avg/Ext file, strips out the HTML (actually ignore it) and then sets up some tables for each day with CSS tags that allow you to pretty it up.

Note:
This version of the script will not work with the newer format of the Avg/Ext html file. See below for a different link:

Scripts Page:
http://www.tnetweather.com/tws-avgext-script.php

It should continue to work after the current bug with the no ending tag for the <FONT stuff that is currently in it as long as the fix is consistent with how the other HTML is used. If not, I will update it after it gets fixed.

One will need to point to the files they want, where they are located etc… and might need some tweaking.

Current working version of this script updated by Mike Challis:

http://discourse.weather-watch.com/

Hi Kevin

I just tried your script - but can

No way to provide any assistance without having a clue where you are pointing at for the data.

Looking at the source, you seem to be missing the

and
tags.

  • Jim

Hi Kevin

Ups - sorry - im pointing at the www.buskelundtoften.dk/vejret/vejrdata/December2007.htm

Best regards,

Henrik

Won’t work with non-english tags. It looks for Engish tags to know when and where to put the data.

Look at the data arrays at the bottom. Will most likely need a lot of tweaking.

` $parts = array(
array(“Daily rain totals”,0),
array(“. on day”,0),
array("Average ",3),
array(“Rainfall for month”,4),
array("Rainfall for year ",4),
array(“Maximum rain per minute”,5),
array(“Maximum temp”,3),
array(“Minimum temp”,3),
array(“Maximum pressure”,3),
array(“Minimum pressure”,3),
array(“Maximum windspeed”,3),
array(“Minimum guest”,4),
array(“Maximum heat index”,4),
array(“Minimum humi”,3),
array(“Maximum humi”,3),
array(“Growing degrees days”,4),
);

// String, action 1 = skip 0 = print 2 = print blank, level, needpart

$extracts = array (
    array("<pre>",1,1,0),
    array("daily report for ",1,0,1),
    array("font",1,0,0),
    array("pre",1,0,0),
    array("<hr>",1,2,0),
    array("-------",2,0,0),
    array("extremes for the month",1,3,1),
    array("extremes for day :",1,0,1),
);`

Hi again Kevin

Oh yes - of course - i will give it a try.

Thanks for your reply.

Best regards,

Henrik

Henrik,

This gets closer…

http://www.tnetweather.com/scripts/wdavgext/test2.php

http://www.tnetweather.com/scripts/wdavgext/test2.txt

Kevin, as usual Very Nice script,tried it out :

http://hobbyweather.com/avg.php

All I have to do is come up with a .gif image for it ?

Thank You.-Jeff

Ideally, you would add this to your website current style and change the colors to match.

In your case, it would use your weather websites, current top bar as the title area. and you would use colors that match the style you have there.

You would then have a menu item pointing to that “page”

Kevin, Yes I am not very good at this yet, I have to try someone’s own work then spend a week trying to get it in my stuff.

Thanks Again.-Jeff

Try this CSS… that will get you started…

        body { font-family: verdana, san-serif; background-color: #FFFFFF; color: #000000;}
        a { font-size: 80%; text-decoration: none; color: #000000; font-weight: bold; 
            padding-right: 340px; }
        a:visit { text-decoration: none; color: #000000; font-weight: bold;  }
        a:hover { text-decoration: underline; color: #000000; font-weight: bold;  } 
        h1 { color: #000000; font-size: 120%; background-color: #639532; width: 60%; 
            padding: 2px; border: 1px solid #000000;
            border-right: 3px solid #000000; border-bottom: 3px solid #000000; }
        h2 { font-size: 110%; }
        h3 { color: #000000; font-size: 100%; background-color: #639532; width: 30%; 
            padding: 2px; border: 1px solid #000000;
            border-right: 3px solid #000000; border-bottom: 3px solid #000000;}
        .tbl { width: 65%; border: 1px solid #000000; border-collapse: collapse; 
            border-right: 4px solid #000000; border-bottom: 4px solid #000000; }
        .left  { color: #000000; padding-left: 5px; font-family: verdana; width: 250px; 
            border: 1px solid black; background-color: #D1F7AD;}
        .right { color: #000000; padding-left: 5px; font-family: "courier new", monospace; 
            font-size: 90%; border: 1px solid black; background-color: #D1F7AD;}
        .rtbl { width: 25%; border: 1px solid #4A2409; border-collapse: collapse; 
            border-right: 4px solid #000000; border-bottom: 4px solid #000000; }            
        .rain { text-align: center; color: #000000; padding-left: 5px; 
            font-family: verdana; width: 250px; 
            border: 1px solid black; background-color: #D1F7AD;}

Kevivn, Thank You Very Much, I am on it.
-Jeff

Wow, go away for a few hours and Kevin adds all kinds of new scripts! :lol: Thanks for the new toys Kevin, Merry Christmas! Got it working in no time, now for the right place to add it…hmmmm. Looks like this will need a form type page to pick the month!

Jack

Hi Kevin

Thanks - its looking much better - i tried myself to change some of the words to Danish - but got it all messed up.

There is missing some lines from the December2007.htm - see attached pic where I have marked the missing with red, and the rain totals in the bottom.

www.buskelundtoften.dk/vejret/sample.php

Thanks for anohter great script.

Best regards,

Henrik


Hi again

I played a little with your script and got a bit further - here is the result:

http://www.buskelundtoften.dk/vejret/avgextract.php

Now my problem is - why are the rest of the values under the graph-link?

Still missing the totals in the bottom.

Best regards,

Henrik


avgextract.txt (7.31 KB)

The format of your file is not consistent with what I tested against. In the html files that I tested against, the last entry in the table for each day was Maximum Heat Index.

You “sometimes” have an extra line called Regn i dag which is not in any of the charts that I tested against. The result is that the table is closed before that tag shows up.

I’ve updated the test2 script above to just ignore those lines completely.

http://www.tnetweather.com/scripts/wdavgext/sample2.php

http://www.tnetweather.com/scripts/wdavgext/sample2.txt

Hi Kevin

Fantastic - its working. I think the “Regn i dag” line only occures when we have had rain. (It means “Rain today”)

Just an small issue - I like to have my pages validated - and there seems to be a couple of errors:

Line 39: shoud be removed
Line 501: shoud be removed

Thank you very much for all your help and great scripts.

Best regards,

Henrik

Originally they were stripped… Seems that I reintroduced them when I redid the script.

Add the U in the line:

`preg_match(“/Daglig rapport for (.*)</”,$value,$found);

preg_match(“/Daglig rapport for (.*)</U”,$value,$found);`

Regex is greedy…