Export to CSV every hour

Hi everyone,

I have simple table in the vision.

And I would like that this table save every hour in CSV.
I can do this in button, but I want this automatically in every hour.

Can you help me about this?

If you need more information about this, just ask me.

Thank you
Bence

You can run your code in a gateway timer script.

Dont point to the table though, make the same query your tables uses, but here

https://docs.inductiveautomation.com/display/DOC81/Gateway+Event+Scripts#GatewayEventScripts-TimerScripts

Thank you the answer!!

But doesn't work for me. I don't know why.
Here my code:

And here is the problem:
event

Do you have idea what is the problem?

Thank you!

You are pointing to the table... the gateway where you are running the script has no idea of that data.

2 Likes

What fills you table?
A db call? a tag read?
do that in the timerscript, instead of refering to the table

1 Like

Not the point of this post but I highly recommend you get used to using https://docs.inductiveautomation.com/display/DOC81/system.date over import datetime. The objects you get from system.date.* functions play nice with all other ignition components.

1 Like

Okay,it was my fault. You write it before.
It this table have just tag read.

1 Like

Then use this:

https://docs.inductiveautomation.com/display/DOC81/system.tag.readBlocking

And write the results to the CSV

1 Like

As an aside, if you want this to run "every hour, on the hour", you should be using the "Scheduled" script type, not the "Timer" type. Timer scripts will run "every hour, from whenever the script manager started up after the gateway last restarted". Scheduled scripts allow you to define execution times much more explicitly.

3 Likes