Page 1 of 3

SQL dayfile data Viewer

Posted: Sun 22 Jan 2017 12:28 pm
by kocher
Here is another way to see our daily data taken from the table, created by cumulusMX, "dayfile".

Demo: http://kocher.es/cumulusMX/datatables/e ... le-sql.php

This is possible thanks to the plugin created by https://www.datatables.net/

The advantages of this presentation in table form are:
- Speed. The query to our dayfile table is very fast.
- The columns are rearranged at will by simply pressing on a column heading.
- The last row of the table, presents a summary of the rows (The minimum temperature value, sometimes fails).
- The variables stand out with a color gradient, taken as a function of their value.
- The search is done in the format yyyy-mm-dd (the format of the field LogDate):

2016-10 filters the month of October 2016
-08-15 filters every day August 15th of every year

Installation:
- Download file: http://kocher.es/cajon/DataTables-cumulus-dayfile.rar (2221 KB)
- Unzip this file
- Install your content on our website, in a folder named as we want.

-Edit the file:

./examples/server_side/scripts/server_processing.php

Line 22: $ table = 'dayfile'; // sometimes called Dayfile

Lines 80-84:

Code: Select all

'User' => 'Our username',
'Pass' => 'Our password',
'Db' ​​=> 'Database name'
'Host' => 'The address of our mysql hosting'
Now, we call from our browser, to file:

../examples/server_side/dayfile-sql.php

I hope you find it useful :)

Re: SQL dayfile data Viewer

Posted: Sun 22 Jan 2017 3:52 pm
by PaulMy
Very nice, and I am learning Spanish (not) http://www.komokaweather.com/mysql/data ... le-sql.php and it goes back to 2008-10

Thank you for sharing.

Enjoy,
Paul

Re: SQL dayfile data Viewer

Posted: Sun 22 Jan 2017 4:58 pm
by Mapantz
Nice work! I'll have a look later this evening.

You're right about how fast it is.. I typed 2016-01, 2016-02, 2016-03 etc etc.. and it is almost instantaneous. Great job. :)

Re: SQL dayfile data Viewer

Posted: Sun 22 Jan 2017 6:03 pm
by grwkak
Also playing - like the speed and format.

http://wilsonsweather.host-ed.me/DataTa ... le-sql.php

Doing some conversion to English and Imperial units. Color codes will need adjusting. Not sure why but getting a NaN in the windrun sum.

Guy

Re: SQL dayfile data Viewer

Posted: Mon 23 Jan 2017 1:03 am
by Mapantz
Something missing from the package.. ;)
dataTables.scroller.js
Install that to: ../examples/resources

The table will now list the entire contents (pretty fast, I might add) which you can scroll through. It also automatically updates the text: Displaying 1 - 14 days from 328 days to show you exactly how many days are on view at a given time. :P

http://www.warehamwx.co.uk/cumulus/dayfile_sql.php

Re: SQL dayfile data Viewer

Posted: Mon 23 Jan 2017 4:37 am
by PaulMy
Thanks kocher, I really like this. And doing the full db as per Mapantz update is great, thanks for that. This is something I always wished for but don't have the ability to do by myself.

Just a couple of interesting facts on my 3,013 days of data:
Of these 3013 days of data there were 1,119 days that had a low of below 0.0°C (days of frost)
Of the 3,013 days there were 400 days that had a high that was below 0.0°C (days that had frost all day).

Now if I could figure out how to add or show more of the dayfile.txt data, i.e. sunshine, heating and cooling degree days...

Enjoying,
Paul

Re: SQL dayfile data Viewer

Posted: Mon 23 Jan 2017 1:54 pm
by kocher
I would like to add more variables to our table, but the reality is that I can not.
In the file "server_processing.php" yes, you can incorporate all the fields of the table dayfile;
but when you add any of them to the "dayfile-sql.php" file, everything stops working :groan:

Re: SQL dayfile data Viewer

Posted: Mon 23 Jan 2017 1:59 pm
by Mapantz
kocher wrote:I would like to add more variables to our table, but the reality is that I can not.
In the file "server_processing.php" yes you can incorporate all the fields of the table dayfile;
but when you add any of them to the "dayfile-sql.php" file, everything stops working :groan:
I don't really have enough brain power to do much to it. I could probably add solar radiation, as that would just about fit in to the table when using my custom widths. I suspect that you would need a horizontal scrollbar to fit in more contents such as humidity/degree days/dew point etc..

Maybe someone would be able to expand on it in the future, as it is a very useful script imo. :)

Re: SQL dayfile data Viewer

Posted: Wed 25 Jan 2017 11:20 pm
by grwkak
Here is my php file adapted to US/imperial units. The color scales are adapted to the range of weather I see here in NE Ohio.
I do not know much about php etc so it could do with some cleaning up but it seems to work. Not sure about the pressure - may need to redo the colors.

Guy
dayfile-sql.zip

Re: SQL dayfile data Viewer

Posted: Fri 27 Jan 2017 11:09 pm
by BeaumarisWX
Thank you greatly Kocher and Mapantz.
I have adapted it to my Saratoga Template.
sfdayfilesql.png
Kind Regards,

Re: SQL dayfile data Viewer

Posted: Thu 23 Mar 2017 5:29 pm
by 92merc
Digging up an old thread here. I was able to get the dayfile scripts configured and uploaded. 2 issues hopefully someone can help with.

Can the Date format be changed to MM/DD/YYYY?

My totals at the bottom are in US, but the labels inside are coming up with metric instead of US. The numbers are right, just the labels are wrong.

Thanks.

http://www.bismarckweather.net/dayfile/ ... le-sql.php

Re: SQL dayfile data Viewer

Posted: Thu 23 Mar 2017 8:02 pm
by kocher

Can the Date format be changed to MM/DD/YYYY?
To change the date format. You must edit the file: "./server_side/scripts/server_processing.php"

Approximately, on line 39, you must change:

Code: Select all

		'formatter' => function( $d, $row ) {
			return date( 'Y/m/j', strtotime($d));
			
to

Code: Select all

		'formatter' => function( $d, $row ) {
			return date( 'm/j/Y', strtotime($d));

Re: SQL dayfile data Viewer

Posted: Thu 23 Mar 2017 8:37 pm
by 92merc
Thank you. And I saw my labels in the PHP file as well that I updated.

Re: SQL dayfile data Viewer

Posted: Tue 23 May 2017 11:17 am
by Warrandyte
Mapantz wrote:Something missing from the package.. ;)

dataTables.scroller.js

Install that to: ../examples/resources

The table will now list the entire contents (pretty fast, I might add) which you can scroll through. It also automatically updates the text: Displaying 1 - 14 days from 328 days to show you exactly how many days are on view at a given time. :P

http://www.warehamwx.co.uk/cumulus/dayfile-sql.php
Thanks. Done a great job on the site. Have you templated your creation?
Rob

Re: SQL dayfile data Viewer

Posted: Sun 23 Jul 2017 2:37 pm
by Hunter362
Where did you change the "highlight" code for the rows? I can't seem to find the right one.