CSV Export details
#1
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.
Reply
#2
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.
Reply
#3
Ok, so what' your suggestion about it?
What's a script the generate the file?
Thanks.
Reply
#4
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: 28)

BR,

Erwin
Reply
#5
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
Reply
#6
(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.


Attached Files Image(s)
   
Reply
#7
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
Reply
#8
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?
Reply
#9
Please check this post:
https://forum.logicmachine.net/showthread.php?tid=1216

You can find there some additional info about current trend API.
Reply
#10
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.
Reply
#11
(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.
Reply
#12
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
Reply
#13
You can find a solution in below post:
https://forum.logicmachine.net/showthrea...trends+api
Reply


Forum Jump: