Welcome to the Cumulus Support forum.

Latest Cumulus MX release v3.0.0 build 3050 - 1 May 2019.
Legacy Cumulus 1 release v1.9.4 (build 1099) - 28 November 2014

See the Wiki for downloading either version.

ImportCumulusFile.php - version 2.0

Other discussion about creating web sites for Cumulus that doesn't have a specific subforum

Moderator: daj

User avatar
mcrossley
Posts: 5601
Joined: Thu 07 Jan 2010 9:44 pm
Weather Station: Davis VP2
Operating System: Stretch Lite rPi
Location: Wilmslow, Cheshire, UK
Contact:

Re: ImportCumulusFile.php - version 2.0

Post by mcrossley » Fri 21 Dec 2012 9:35 pm

That will do it, or
retainVal=7
retianUnit=day

thekow
Posts: 53
Joined: Wed 05 Dec 2012 8:39 am
Weather Station: w1080
Operating System: Virtualbox XP environment
Location: Australia
Contact:

Re: ImportCumulusFile.php - version 2.0

Post by thekow » Fri 21 Dec 2012 9:56 pm

What is the best practice to import the realtime data. At the moment i am storing 3 hours of data in a txtfile. Then processing it every 3 hours via the import php. Does this script overwrite identical entries or ignore them? Trying to figure out if i am going to run into issues when i eventually start running the recent graphs.

User avatar
mcrossley
Posts: 5601
Joined: Thu 07 Jan 2010 9:44 pm
Weather Station: Davis VP2
Operating System: Stretch Lite rPi
Location: Wilmslow, Cheshire, UK
Contact:

Re: ImportCumulusFile.php - version 2.0

Post by mcrossley » Fri 21 Dec 2012 10:05 pm

The realtime table has a primary key on the date time so it will not allow duplicate rows.

I am running the ImportCumlusFile.PHP script from the command line on my web server once a minute to populate the real time table.

User avatar
laulau
Posts: 524
Joined: Tue 13 Oct 2009 10:52 pm
Weather Station: WeatherDuino Pro2
Operating System: Win 7
Location: Meyenheim, Alsace, FR
Contact:

Re: ImportCumulusFile.php - version 2.0

Post by laulau » Fri 24 May 2013 3:37 pm

Hi,
I'm trying this script to generate a realtime database.
I set up a cron job to populate the database (every 5 min).
I started this 3 hours ago and the database is populated but the old data are not deleted!
my command line :

Code: Select all

php /PathToWeb/test/ImportCumulusFile.php type=realtime key=**** table=Realtime file=/PathToWeb/realtime.txt retainVal=1 retainUnit=hour
The database should contain only 1 hour of data but for the moment all the data are kept in.
I tryed the command manualy :
  • 24/05/13 - 17:29:49
    Importing to table: Realtime ...
    Processing realtimefile: ../realtime.txt
    Inserting data... done.
    Deleting old realtime records...done.
    24/05/13 - 17:29:51
But the old realtime records are still here.

What is going wrong ?
Thanks
Laurent

Image

User avatar
laulau
Posts: 524
Joined: Tue 13 Oct 2009 10:52 pm
Weather Station: WeatherDuino Pro2
Operating System: Win 7
Location: Meyenheim, Alsace, FR
Contact:

Re: ImportCumulusFile.php - version 2.0

Post by laulau » Fri 24 May 2013 7:55 pm

Hi again,
After a longer observation, it seem's that my realtime database retains about 3 hours data (one hour was expected with my parameters).
there are 36 lines in the database.
The script run every 5 min, with retainVal=1 retainUnit=hour i should only have 12 lines in the DB.

I don't understand where it hangs!
Laurent

Image

User avatar
laulau
Posts: 524
Joined: Tue 13 Oct 2009 10:52 pm
Weather Station: WeatherDuino Pro2
Operating System: Win 7
Location: Meyenheim, Alsace, FR
Contact:

Re: ImportCumulusFile.php - version 2.0

Post by laulau » Sat 25 May 2013 10:12 am

It's a time zone issue i think.
I have put 2:00 instead of 0:00 in this part of the code :

Code: Select all

if (!mysql_query('SET time_zone="+[b]2[/b]:00"')) {
        die('Error: TZ Statement');
    }
And now it works i have only 1 hour of data instead 3 hours.

What would happened at the next hour change (winter time UTC+1 <> summer time UTC+2) ?
Is there a way to make this change in the script automaticaly?
Laurent

Image

User avatar
mcrossley
Posts: 5601
Joined: Thu 07 Jan 2010 9:44 pm
Weather Station: Davis VP2
Operating System: Stretch Lite rPi
Location: Wilmslow, Cheshire, UK
Contact:

Re: ImportCumulusFile.php - version 2.0

Post by mcrossley » Sat 25 May 2013 10:24 am

I need to look at the tz again, I thought that forcing the time zone to UTC would avoid these sorts of problems - obviously not.

Post Reply