Page 3 of 9

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

Posted: Thu 04 Feb 2010 9:28 pm
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.

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

Posted: Thu 04 Feb 2010 9:53 pm
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 ;)

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

Posted: Thu 04 Feb 2010 10:11 pm
by n9mfk
Hi David,
im with e-rice.net ImportCumulusFile.php in my web root
Beau

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

Posted: Thu 04 Feb 2010 10:11 pm
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:

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

Posted: Thu 04 Feb 2010 10:59 pm
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!

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

Posted: Fri 05 Feb 2010 8:09 am
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

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

Posted: Fri 05 Feb 2010 9:15 am
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?

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

Posted: Fri 05 Feb 2010 9:21 am
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.

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

Posted: Fri 05 Feb 2010 9:24 am
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

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

Posted: Fri 05 Feb 2010 9:31 am
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

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

Posted: Fri 05 Feb 2010 9:31 am
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...

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

Posted: Fri 05 Feb 2010 9:34 am
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

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

Posted: Fri 05 Feb 2010 9:40 am
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.

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

Posted: Fri 05 Feb 2010 9:44 am
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

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

Posted: Fri 05 Feb 2010 9:45 am
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.