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 »

Well it depends on your hosting but you have to make first a database also mentioned in the wiki concerning this topic , a database needs a user (mostly named username) and you have to set the privileges for the user , give it all priviliges you also have to make a password.

In this case you have a databasehost (mostly named localhost),a database a databaseuser and a databasepassword

Fill these parameters in the php file ftp the php and .txt file(s) to your webspace. After that you can acces the php file just as you did before, a dabasetable will be created autmatically.

I think I've just copied the wiki :) It should be easy if you have plesk by your hostingprovider.
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 »

n9mfk wrote:Hi David,
i did this

Code: Select all

http://www.n9mfk.com/ImportCumulusFile.php?type=monthly&key=letmein&table=monthlyfile&file=/data/Aug09log.txt
an got failed to open file
Your file loation is wrong. It is raltive to where you are running the script from, and in your case it should be

Code: Select all

http://www.n9mfk.com/ImportCumulusFile.php?type=monthly&key=letmein&table=monthlyfile&file=data/Aug09log.txt
notice the / is now removed from the start of data

the next error is you using an old version of PHP on your server that does not support the mysqli_close command. My error there as I thought I had used all the old commands for maximum compatipility. I will fix that in the next update.

However, you should now have a table called monthlyfile with all the data -- as I think I have imported it ;)
David
kippfordweather.uk
Cumulus MX & Raspberry Pi
n9mfk
Posts: 845
Joined: Sun 10 May 2009 8:52 pm
Weather Station: davis vp2 Serial datalogger
Operating System: Windows 7 64-bit
Location: Springfield, IL

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

Post by n9mfk »

Hi David,
im with e-rice.net ImportCumulusFile.php in my web root
Beau
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 »

However, you should now have a table called monthlyfile with all the data -- as I think I have imported it
Beau you should change the key in the php file :lol:
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 »

Version 1.1b available

Make sure you delete any current tables created with previous versions so that it can create new ones.

This now includes a setting for your decimal separator. If you are in the UK this is a dot so there is nothing to change. If you use a comma, change the setting in the file.

So to recap, the three important variables to consider are date separator, field delimiter on the file, and decimal point notation. The script is set to / , . (that is, the UK). You may need to change these.

I have tested it with the UK and a European format with - ; , settings.

In doing this I have also changed the SQL fields back to numbers (decimal) rather than text (varchar) as I prefer this storage method for number to allow better calculations.

Let me know how it goes....I think we are getting their with international support!
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 »

Run the script tonight everything succeeded before running I'd made a querysript (very basic) if you are interested you can use it and modify it (be sure to fill out databasename,databaseuser and password.

The extension should be .php in this case ask.php you can make a link to it or whatever in your browser. I think it's a good way to see how the database is accessed and gives output in html although it's not very sophisticated (was a lesson for me)

Example availble for the time being on my playground http://www.apeldoorn.tk/weer/ask2.php


BTW Steve the new script does the job just wondering why you use two decimals in some values there the second after the decimal is always 0 (zero) in my case
You do not have the required permissions to view the files attached to this post.
User avatar
steve
Cumulus Author
Posts: 26702
Joined: Mon 02 Jun 2008 6:49 pm
Weather Station: None
Operating System: None
Location: Vienne, France
Contact:

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

Post by steve »

nitrx wrote:BTW Steve the new script does the job just wondering why you use two decimals in some values there the second after the decimal is always 0 (zero) in my case
I don't. When I've seen this before, it's when the user has been editing the files. Cumulus uses Delphi system functions for formatting numbers; something very odd would have to be wrong with those if they started producing more than one decimal. Could you show me an example of a full line from a log file containing one?
Steve
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 »

Could you show me an example of a full line from a log file containing one?
No I can't so I think David has to correct the script for writing to the database.
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 »

I wonder if that question was actually at my script, which does show two decimal places for some numbers. Makes no difference to calculations. I made it two just in case some of the other weather stations produced two decimal places for any values
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 »

I asked it for you script because I think when I do the output I will get values with 2 decimals (haven't tried yet if the output is with one decimal I don't mind but 2 are not esthetic
User avatar
steve
Cumulus Author
Posts: 26702
Joined: Mon 02 Jun 2008 6:49 pm
Weather Station: None
Operating System: None
Location: Vienne, France
Contact:

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

Post by steve »

Right, sorry, I completely misunderstood the question! :bash:

You mean that some numbers look like this: 2.20 instead of this: 2.2

I thought you meant (and I have seen this is some people's data due to editing) this: 2.2.0 instead of this: 2.2,0 (so a decimal point has accidentally been typed instead of a comma).

I'll go back to sleep...
Steve
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 »

steve wrote:You mean that some numbers look like this: 2.20 instead of this: 2.2
Yes, that is how I would import it to SQL - 2.20

Which of course is just the same as 2.2

If you (Steve) can confirm nothing Cumulus produces is more than one decimal place I can change it
David
kippfordweather.uk
Cumulus MX & Raspberry Pi
User avatar
steve
Cumulus Author
Posts: 26702
Joined: Mon 02 Jun 2008 6:49 pm
Weather Station: None
Operating System: None
Location: Vienne, France
Contact:

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

Post by steve »

daj wrote:If you (Steve) can confirm nothing Cumulus produces is more than one decimal place I can change it
There are a number of values which can have more than one (i.e two) dp, depending on the units being used. Inches of rain, pressure in inches of mercury etc. For Davis users, pressure gets an extra decimal place - in mb and hPa it's 2 dp, and in inHg it's 3 dp.
Steve
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 »

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
User avatar
steve
Cumulus Author
Posts: 26702
Joined: Mon 02 Jun 2008 6:49 pm
Weather Station: None
Operating System: None
Location: Vienne, France
Contact:

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

Post by steve »

I should really write a 'developer's guide' where things like this are documented (also that thing with the date formats and the CSV). Things about the way Cumulus works that an 'ordinary' user doesn't really need to know (but might find interesting) but which an add-on developer does need to know.
Steve
Post Reply