Logic Machine Forum
CSV Export details - Printable Version

+- Logic Machine Forum (https://forum.logicmachine.net)
+-- Forum: LogicMachine eco-system (https://forum.logicmachine.net/forumdisplay.php?fid=1)
+--- Forum: Scripting (https://forum.logicmachine.net/forumdisplay.php?fid=8)
+--- Thread: CSV Export details (/showthread.php?tid=1234)



CSV Export details - Domoticatorino - 13.02.2018

Dear all,
before writing, I read all post about this thread but no post clearify what I would like to do.

I would like to export and send by mail all my csv files log. After that I would like to delate the csv file in order to keep the memory clean and light.

What do you suggest? Furthermore I do not konw how I can clean memory of trend manually? 

Thank you for your help.

Regards.


RE: CSV Export details - admin - 13.02.2018

In some cases you don't need to store the file at all, just generate it in your script and send via e-mail as attachment.

Trends cannot be "cleaned". Database is allocated to support all data at once, so even trend without any data still has the maximum size depending on selected data range.


RE: CSV Export details - Domoticatorino - 13.02.2018

Ok, so what' your suggestion about it?
What's a script the generate the file?
Thanks.


RE: CSV Export details - Erwin van der Zwart - 14.02.2018

Hi,

Try this, the attachment is never saved:
.lua   Mail 1 year of trenddata with hourly data points version 1_2.lua (Size: 6.18 KB / Downloads: 73)


BR,

Erwin


RE: CSV Export details - Erwin van der Zwart - 19.02.2018

Hi,

See this article on how to set start - end range on trend fetching by using UNIX format timestamps:

http://www.openrb.com/docs/trends-new.htm

I don't think you can fetch smaller data set then 1 day, you have to get the values from the result yourself, when the trend resolution is 5 minutes you get a set of 288 points, then each 12 points are equal to 1 hour, so the points from 15:00 to 16:00 will be data[180] to data[191], when the trend resolution is set to 1 hour the point will be data[15]

BR,

Erwin


RE: CSV Export details - Domoticatorino - 19.02.2018

(19.02.2018, 19:01)Erwin van der Zwart Wrote: Hi,

See this article on how to set start - end range on trend fetching by using UNIX format timestamps:

http://www.openrb.com/docs/trends-new.htm

I don't think you can fetch smaller data set then 1 day, you have to get the values from the result yourself, when the trend resolution is 5 minutes you get a set of 288 points, then each 12 points are equal to 1 hour, so the points from 15:00 to 16:00 will be data[180] to data[191], when the trend resolution is set to 1 hour the point will be data[15]

BR,

Erwin

Hi Erwin,
I modified start and end date. Now error is the one shown in attchment at line 133. What does it mean?
Thanks.


RE: CSV Export details - Erwin van der Zwart - 19.02.2018

Hi,

Not sure but i think there is no data in your fetched result. You probably have set the scope to narrow. Have you logged the raw result from the fetch command?

BR,

Erwin


RE: CSV Export details - Domoticatorino - 19.02.2018

Consider that this error is shown when I launch the script but the file should be sent in the next 12 hours as per my setting. Or this error stop the script?


RE: CSV Export details - buuuudzik - 19.02.2018

Please check this post:
https://forum.logicmachine.net/showthread.php?tid=1216

You can find there some additional info about current trend API.


RE: CSV Export details - Domoticatorino - 20.02.2018

Thank you buuuudzik!

I use your scritp and it works. But I would like to do is save data in a CSV file and sending it by mail. I cannot mix your script with the one suggest by Erwin.

Thanks.


RE: CSV Export details - buuuudzik - 20.02.2018

(20.02.2018, 11:37)Domoticatorino Wrote: Thank you buuuudzik!

I use your scritp and it works. But I would like to do is save data in a CSV file and sending it by mail. I cannot mix your script with the one suggest by Erwin.

Thanks.

Yes, I understand but maybe you can use same start and end in your script. You can also log every single step to find what is the reason of nil in the result.


RE: CSV Export details - Erwin van der Zwart - 20.02.2018

Hi, 

Like the script says:


--****************** DON'T CHANGE ANYTHING UNDER THIS LINE *****************--
--**************************************************************************--

But you changed this line: 

trends_table = db:getall('Temperatura - Giorno') -- This is not a valid query

Set it back to original:

trends_table = db:getall('SELECT name FROM trends ORDER BY name DESC')

BR,

Erwin


RE: CSV Export details - buuuudzik - 21.02.2018

You can find a solution in below post:
https://forum.logicmachine.net/showthread.php?tid=719&highlight=trends+api