Welcome to the Cumulus Support forum.

Latest Cumulus MX V3 release 3.28.6 (build 3283) - 21 March 2024

Cumulus MX V4 beta test release 4.0.0 (build 4017) - 17 March 2024

Legacy Cumulus 1 release v1.9.4 (build 1099) - 28 November 2014 (a patch is available for 1.9.4 build 1099 that extends the date range of drop-down menus to 2030)

Download the Software (Cumulus MX / Cumulus 1 and other related items) from the Wiki

a PHP import script for DayFile and Monthly log files

Discussion and support for 3rd-party (non-Sandaysoft) tools for Cumulus
User avatar
nitrx
Posts: 1297
Joined: Sun 13 Dec 2009 1:21 pm
Weather Station: WH1080
Operating System: Windows 10
Location: Apeldoorn The Netherlands
Contact:

Re: a PHP import script for DayFile and Monthly log files

Post by nitrx »

Good idea Steve but firts things first (whatever it may be)
User avatar
daj
Posts: 2041
Joined: Tue 29 Jul 2008 8:00 pm
Weather Station: WH1081
Operating System: Pi & MX
Location: SW Scotland
Contact:

Re: a PHP import script for DayFile and Monthly log files

Post by daj »

nitrx wrote:In that case two deciamls are oké I think anyway it doesn't matter I can change the script by myself now because I don't like the output of two decimals ( just a matter of taste ) http://www.apeldoorn.tk/weer/ask2.php
Ron,

Rather than modify the script (which means you need to change it if there are further updates to it) you are far better to format the number when you are displaying it....

So in your code...

Code: Select all

<?php echo number_format($result_ar['MaxTemp'],1); ?></td>
the number_format will change the displayed number to 1 decimal place in this case
David
kippfordweather.uk
Cumulus MX & Raspberry Pi
User avatar
daj
Posts: 2041
Joined: Tue 29 Jul 2008 8:00 pm
Weather Station: WH1081
Operating System: Pi & MX
Location: SW Scotland
Contact:

Re: a PHP import script for DayFile and Monthly log files

Post by daj »

Here's another page driven by the SQL database

http://www.grantownweather.co.uk/year

I user a number of SQL statements to query and return each of the values live based on what year you select
David
kippfordweather.uk
Cumulus MX & Raspberry Pi
User avatar
mcrossley
Posts: 12685
Joined: Thu 07 Jan 2010 9:44 pm
Weather Station: Davis VP2/WLL
Operating System: Bullseye Lite rPi
Location: Wilmslow, Cheshire, UK
Contact:

Re: a PHP import script for DayFile and Monthly log files

Post by mcrossley »

David (or any one else!)

I am having a slight problem with the script.

If I run it against an empty db it creates the table OK, imports the first four lines from my dayfile.txt, then errors with 'failed to insert data' on all subsequent lines.

Rerunning the scirpt produces the same error for all lines in the dayfile.

If I pre-create the table, then the script does not import any rows (same error).

Update: Hmm after leaving it overnight I reran the script, this imported one more row than errored on the rest.

I have attached my dayfile, the errorlog and a screenshot of the table that is created.

Versions:
MySQL: 5.0.87
Apache:1.3.41
PHP: 5.2.10
db/Table: MyISAM

Anyone got any ideas?

Thanks
Mark
You do not have the required permissions to view the files attached to this post.
User avatar
daj
Posts: 2041
Joined: Tue 29 Jul 2008 8:00 pm
Weather Station: WH1081
Operating System: Pi & MX
Location: SW Scotland
Contact:

Re: a PHP import script for DayFile and Monthly log files

Post by daj »

Mark

That is very strange -- I have just ran your dayfile and it imported all 23 entries. I tried letting it create the table, or add to an existing one.

What version of the script are you using 1.1b? (tells you are the top)

Can you confirm what your three delimiters are set to in the script?

thanks
David
kippfordweather.uk
Cumulus MX & Raspberry Pi
User avatar
mcrossley
Posts: 12685
Joined: Thu 07 Jan 2010 9:44 pm
Weather Station: Davis VP2/WLL
Operating System: Bullseye Lite rPi
Location: Wilmslow, Cheshire, UK
Contact:

Re: a PHP import script for DayFile and Monthly log files

Post by mcrossley »

David

Yes, 1.1b, I did not change any delimiters as I use the UK locale, so they are ",/."

Edit: If I 'import' the dayfile directly to the table as a CSV it imports all the rows - tough the date messes up as the order is not US

Mark
User avatar
daj
Posts: 2041
Joined: Tue 29 Jul 2008 8:00 pm
Weather Station: WH1081
Operating System: Pi & MX
Location: SW Scotland
Contact:

Re: a PHP import script for DayFile and Monthly log files

Post by daj »

Let me PM you a different script to try, with some debugging, which may give us a clue
David
kippfordweather.uk
Cumulus MX & Raspberry Pi
User avatar
nitrx
Posts: 1297
Joined: Sun 13 Dec 2009 1:21 pm
Weather Station: WH1080
Operating System: Windows 10
Location: Apeldoorn The Netherlands
Contact:

Re: a PHP import script for DayFile and Monthly log files

Post by nitrx »

daj wrote:
nitrx wrote:In that case two deciamls are oké I think anyway it doesn't matter I can change the script by myself now because I don't like the output of two decimals ( just a matter of taste ) http://www.apeldoorn.tk/weer/ask2.php
Ron,

Rather than modify the script (which means you need to change it if there are further updates to it) you are far better to format the number when you are displaying it....

So in your code...

Code: Select all

<?php echo number_format($result_ar['MaxTemp'],1); ?></td>
the number_format will change the displayed number to 1 decimal place in this case
I've reverted and this syntax works fine but I just saw you made the most values 1 decimal , the yearqueries are on the todo list
User avatar
mcrossley
Posts: 12685
Joined: Thu 07 Jan 2010 9:44 pm
Weather Station: Davis VP2/WLL
Operating System: Bullseye Lite rPi
Location: Wilmslow, Cheshire, UK
Contact:

Re: a PHP import script for DayFile and Monthly log files

Post by mcrossley »

daj wrote:Let me PM you a different script to try, with some debugging, which may give us a clue
David, many thanks that sorted it out for me, I had inadvertently set an 'update' restriction on the non-priveledged user limiting the account to 5 updates/hour. I've removed that restriction and the original script is now working fine :)

Maybe keeping the debug info in the real script would help other people in the future?

Now to work out what to do with this data!

Thanks again
Mark
User avatar
daj
Posts: 2041
Joined: Tue 29 Jul 2008 8:00 pm
Weather Station: WH1081
Operating System: Pi & MX
Location: SW Scotland
Contact:

Re: a PHP import script for DayFile and Monthly log files

Post by daj »

mcrossley wrote:
daj wrote:Let me PM you a different script to try, with some debugging, which may give us a clue
David, many thanks that sorted it out for me, I had inadvertently set an 'update' restriction on the non-priveledged user limiting the account to 5 updates/hour. I've removed that restriction and the original script is now working fine :)
Excellent
Maybe keeping the debug info in the real script would help other people in the future?
Yes, I think that makes sense
David
kippfordweather.uk
Cumulus MX & Raspberry Pi
User avatar
nitrx
Posts: 1297
Joined: Sun 13 Dec 2009 1:21 pm
Weather Station: WH1080
Operating System: Windows 10
Location: Apeldoorn The Netherlands
Contact:

Re: a PHP import script for DayFile and Monthly log files

Post by nitrx »

With the latest import file all my values behind the decicam separator are converted to 0 (zero) I did not notice it yesterday (I think I was daydreaming) the decimal (6,2) or something like that seems to treat everything behind the decimal limiter as 0.

My minimum temp was 0,9 yesterday it showed up as 0.0 the average was 3.0 in the database but the 'good' value should be 3,4

For now I've installed version 1.1a with the varchar , I'm sorry I did not notice this before :oops:
User avatar
daj
Posts: 2041
Joined: Tue 29 Jul 2008 8:00 pm
Weather Station: WH1081
Operating System: Pi & MX
Location: SW Scotland
Contact:

Re: a PHP import script for DayFile and Monthly log files

Post by daj »

Ron

when I was looking at your data yesterday it was fine and did have decimal values. Are you sure you did not change something ?

Varchar will not give accurate results for calculations as it will ignore the decimal --
mySql does not support a comma notation for decimal
David
kippfordweather.uk
Cumulus MX & Raspberry Pi
User avatar
nitrx
Posts: 1297
Joined: Sun 13 Dec 2009 1:21 pm
Weather Station: WH1080
Operating System: Windows 10
Location: Apeldoorn The Netherlands
Contact:

Re: a PHP import script for DayFile and Monthly log files

Post by nitrx »

Hmmm I was also wondering David but I'm not aware of changing something the script wa srun automatically past midnight for an hour ago I had a look at the values (in my database) and found no values behind the 'decimal'so I changed everything but I can reproduce it (will take 15 minutes I think..

--I'm aware of the varchar calculuations but zero is'nt really nothing :D
User avatar
nitrx
Posts: 1297
Joined: Sun 13 Dec 2009 1:21 pm
Weather Station: WH1080
Operating System: Windows 10
Location: Apeldoorn The Netherlands
Contact:

Re: a PHP import script for DayFile and Monthly log files

Post by nitrx »

Well I must have something changed really don't know what ..... everything seems to be fine with the latest version http://www.apeldoorn.tk/weer/ask2.php sorry again for the false alarm :bash:
User avatar
daj
Posts: 2041
Joined: Tue 29 Jul 2008 8:00 pm
Weather Station: WH1081
Operating System: Pi & MX
Location: SW Scotland
Contact:

Re: a PHP import script for DayFile and Monthly log files

Post by daj »

we just need to get your figures right aligned in the table to line them up correctly -- a quick change to your stylesheet!! ;)
David
kippfordweather.uk
Cumulus MX & Raspberry Pi
Post Reply