0

I'm pulling data from mysql, timestamp and int value then converting everything to json. I have a problem, that there is a lot of data and i need to filter everything to reduce amount of it.

Example:

{timestamp:"2016-10-11 09:43:12",value:"1"},
{timestamp:"2016-10-11 09:43:12",value:"2"},
{timestamp:"2016-10-11 09:42:53",value:"3"},
{timestamp:"2016-10-11 09:42:52",value:"0"},
{timestamp:"2016-10-11 09:43:45",value:"0"},
{timestamp:"2016-10-11 09:43:13",value:"0"},
{timestamp:"2016-10-11 09:43:13",value:"0"},
{timestamp:"2016-10-11 09:43:13",value:"0"},
{timestamp:"2016-10-11 09:43:13",value:"0"},
{timestamp:"2016-10-11 09:43:13",value:"0"},
{timestamp:"2016-10-11 09:43:13",value:"0"}

I need to remove same values if they repeating in 10 minutes period. that output would be like that:

{timestamp:"2016-10-11 09:43:12",value:"1"},
{timestamp:"2016-10-11 09:43:12",value:"2"},
{timestamp:"2016-10-11 09:42:53",value:"3"},
{timestamp:"2016-10-11 09:42:52",value:"0"}

Maybe anyone has some ideas to filter everything before outputting everything. Now in my database is about 200k. rows of data.

UPDATE:

I filtered data in Matlab with this code:

    naujas_masyvas = 0; 
naujas_masyvas2 = 0;
% last_valaue = VarName31[1]
index=1;
for i=2:1:3472
 last_value = VarName31(i-1);
 value = VarName31(i);   
 if value ~= last_value 
     naujas_masyvas(index) =last_value;
     naujas_masyvas(index+1) = value;
     naujas_masyvas2(index) = datenum(VarName2(i-1,1));
     naujas_masyvas2(index+1) =  datenum(VarName2(i,1));
     index = index +2;
 end


end
naujas_masyvas3 = VarName31;
naujas_masyvas4= datenum(VarName2);
% hold on;

plot(naujas_masyvas2, naujas_masyvas,'c*', naujas_masyvas4, naujas_masyvas3,'red:')
% plot(naujas_masyvas2, naujas_masyvas,'c*')

Maybe someone has ideas how to implement everything in php

Thanks.

halfer
  • 19,824
  • 17
  • 99
  • 186
arnas120
  • 23
  • 4
  • 1
    convert datetime to date then group by timestamp (in date) and value – YVS1102 Oct 17 '16 at 08:31
  • Possible duplicate of [Group mysql query by 15 min intervals](http://stackoverflow.com/questions/2793994/group-mysql-query-by-15-min-intervals) – KikiTheOne Oct 17 '16 at 08:45
  • are you trying to group the result by value? – Wreeecks Oct 17 '16 at 10:37
  • Basically i need to filter data if in 10min. period value not changing. So if Value = 0 whole 10mins. ignore that value and keep only one value that equals to 0 – arnas120 Oct 18 '16 at 05:33

0 Answers0