Page 3 of 4

Re: Realtime and mysql download available.

Posted: Wed 05 Sep 2012 9:38 am
by mproper23
hi.

i use the actual version of cumulus.


here's a link to my realtime.txt
http://www.volksfrontderhorde.de/wetter/realtime.txt

Thank you for your time!

Re: Realtime and mysql download available.

Posted: Thu 06 Sep 2012 9:30 am
by richardmhowell
mproper23 wrote:hi.

i use the actual version of cumulus.


here's a link to my realtime.txt
http://www.volksfrontderhorde.de/wetter/realtime.txt

Thank you for your time!
the problem you have is becuase your date is formatted like this 3.12.2012 the script is written to replace the date formatted like this 3/12/2012 see below;

Code: Select all

// This line should convert any date in the form dd/mm/yy to yy/mm/dd
   $linemysql = preg_replace('/(\d{2})\/(\d{2})\/(\d{2})/' , "\\3/\\2/\\1" , $linemysql)
I am not 100% sure how to change this without making the sky fall in, it might be easier to change your cumulus settings.

Not much use i know i will see if i can get it working for you

Rich

Re: Realtime and mysql download available.

Posted: Thu 06 Sep 2012 1:27 pm
by mcrossley
richardmhowell wrote: the problem you have is becuase your date is formatted like this 3.12.2012 the script is written to replace the date formatted like this 3/12/2012 see below;

Code: Select all

// This line should convert any date in the form dd/mm/yy to yy/mm/dd
   $linemysql = preg_replace('/(\d{2})\/(\d{2})\/(\d{2})/' , "\\3/\\2/\\1" , $linemysql)
I am not 100% sure how to change this without making the sky fall in, it might be easier to change your cumulus settings.
I think it would be...

Code: Select all

// This line should convert any date in the form dd/mm/yy to yy/mm/dd
   $linemysql = preg_replace('/(\d{2})\.(\d{2})\.(\d{2})/' , "\\3/\\2/\\1" , $linemysql)
But what do know about PHP! I'm assuming 'dot' is a special char that needs escaping.

Re: Realtime and mysql download available.

Posted: Thu 06 Sep 2012 1:41 pm
by steve
mcrossley wrote:I think it would be...
I thought the same, and posted it but then deleted it as I wasn't sure :oops:

Re: Realtime and mysql download available.

Posted: Thu 06 Sep 2012 2:01 pm
by gemini06720
The code seems to produce the same results with and without the '\' escaping character.

'mproper23' 'realtime.txt' file contains the date in the following format:

Code: Select all

06.09.12
with the escape character:

Code: Select all

$linemysql = preg_replace('/(\d{2})\.(\d{2})\.(\d{2})/' , "\\3/\\2/\\1" , $linemysql);
without the escape character:

Code: Select all

$linemysql = preg_replace('/(\d{2}).(\d{2}).(\d{2})/' , "\\3/\\2/\\1" , $linemysql);
produce:

Code: Select all

12/09/06

Re: Realtime and mysql download available.

Posted: Thu 06 Sep 2012 3:26 pm
by steve
Could it be that in the 'unescaped' case, the dot represents 'any character' and hence that form would be a good general case replacement for the original (as some people might have other date separators, e.g. "-")?

Re: Realtime and mysql download available.

Posted: Thu 06 Sep 2012 3:47 pm
by mcrossley
It does and it would Steve.

Re: Realtime and mysql download available.

Posted: Fri 07 Sep 2012 9:38 am
by gemini06720
I concur with Mark - I tried different separators and different combinations of separators and I always end up with the date in the 'yy/mm/dd' format.

Re: Realtime and mysql download available.

Posted: Thu 11 Oct 2012 9:41 am
by Boym
I made a little change in script.
Now he take a date in european format; 11.10.12 and I added new column in table.
Now script works.

Re: Realtime and mysql download available.

Posted: Fri 16 Nov 2012 5:46 pm
by SpeedyGJ
Hellow!

Setup OK
Real.php: File not found. Make sure you specified the correct path.
Database.php: Empty!

The pad to the realtime.txt is: /httpdocs/weer/realtime.txt but thats not OK!
Even as: http://www.weerstationdokkum.nl/weer/realtime.txt
I have everything try to make this working but nothing work!
What do i wrong?

Even the database.php is empty! Its this correct?

Re: Realtime and mysql download available.

Posted: Fri 16 Nov 2012 10:19 pm
by gemini06720
Are you using the scripts found in the 'realtime.zip' (attached to a message released on October 11, 2012?

If so, you need to make modification to (at least) the 'real.php' script.

Unfortunately, the script designer improperly 'assumed' that everyone was using the same date format as was used on his/her computer (poor programming)!

The date format produced by your Cumulus is in this format '16-11-12' - the script is expecting the date format to be in this format '16.11.12' - thus the script is producing an error message that, on most servers, will not be displayed.

To be able to process the 'realtime.txt' produced by your Cumulus, you need to change line 37 of 'real.php' from:

Code: Select all

$tmp_date = explode( ".", $linearray[0] );
to

Code: Select all

$tmp_date = explode( "-", $linearray[0] );
(the period has to be replaced with a dash)

I have just done some tests with the 3 scripts...
  • - the 'sqlsetup.php' scripts did not create the database - it only created the 'realtime' table - you have to manually create the database using something such as phpMyAdmin on an Apache server;
    - the relative path to the 'realtime.txt' data files has to be well specified in the 'real.php' script - otherwise the error message "File not found. Make sure you specified the correct path." will be displayed;
    - the 'database.php' script, as specified, reads the last 288 entries of the database (according to the description in the script, the last 24 hours - that would mean one entry every 12 minutes) and produces 43 arrays, each array containing 288 values;
    - the 'database.php' script has not been designed to display anything - the arrays produced by the 'database.php' script have to be used within a web page template.

I do hope the information provided will help you resolve your situation... If not, just post again explaining as clearly as possible the actions you have taken and the results you are (or are not) obtaining.

Re: Realtime and mysql download available.

Posted: Fri 30 Nov 2012 11:13 am
by inaciovieira
Can some one help me how to put the values in to a graphic. I have been around this and canĀ“t do it.

Re: Realtime and mysql download available.

Posted: Fri 30 Nov 2012 11:32 am
by mcrossley
Ray, would it not be better to replace the explode() with a preg_split(), then t will work with any delimiters?

Code: Select all

$tmp_date = preg_split("/[^0-9]/", $linearray[0] );
Another observation about these scripts, would it not be better to keep the SQL table column names the same as the corresponding webtag names? This is what David did with the ImportCumulusFiles scripts in the Wiki (and I have extended), and I have also done with my realtime.txt log parser. Keeping consistency is usually a good thing.

In fact it may be useful to add this functionality to the already exisiting ImportCumulusFiles scripts? The script already handles the monthly and dayfile logs in a very similar manner.

To be honest I'd forgotten about this script when I wrote my realtimeLogParser :roll:

Re: Realtime and mysql download available.

Posted: Tue 04 Dec 2012 2:38 pm
by kc2kzz
I just set this up and getting strange results.

The log shows that data is being inserted into the table:

121204 9:32:59 72 Connect cumulus@localhost on
72 Init DB weather
72 Query insert into realtime values('','12/12/04','09:32:44','50.4','96','49.3','0.0','0.0','46','0.00','0.15','30.270','NE','0','mph','F','in','in','1.6','+0.002','0.21','15.75','0.01','64.2','47','50.4','+0.8','50.4','09:32','42.7','00:12','2.0','08:55','5.0','08:13','30.280','00:10','30.256','05:33','1.9.3','1054','1.0','50.4','52.3','0','0.000','0','114','0.00','1','1','0','ESE','250','ft','50.3','0.0','238','0','')
72 Query insert into realtime values('','')
72 Quit

but I don't see any data in the database:
MySQL returned an empty result set (i.e. zero rows). ( Query took 0.0009 sec )
SELECT *
FROM `realtime`
LIMIT 0 , 30

Re: Realtime and mysql download available.

Posted: Tue 04 Dec 2012 3:20 pm
by kc2kzz
Debugging shows this:

$ php real.php
PHP Deprecated: Function split() is deprecated in /home/www/tmp/real.php on line 37

Deprecated: Function split() is deprecated in /home/www/tmp/real.php on line 37
PHP Notice: Undefined offset: 2 in /home/www/tmp/real.php on line 53

Notice: Undefined offset: 2 in /home/www/tmp/real.php on line 53