# Export to CSV every hour

**URL:** <https://forum.inductiveautomation.com/t/export-to-csv-every-hour/85545>\
**Category:** Ignition\
**Tags:** ignition81, vision\
**Created:** [February 12, 2024, 9:17am UTC](https://forum.inductiveautomation.com/t/export-to-csv-every-hour/85545 "2024-02-12T09:17:13Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Molnar\_Bence](https://avatars.discourse-cdn.com/v4/letter/m/c68b51/32.png) [@Molnar\_Bence](https://forum.inductiveautomation.com/u/Molnar_Bence)\
**Post date:** [February 12, 2024, 9:17am UTC](https://forum.inductiveautomation.com/t/export-to-csv-every-hour/85545/1 "2024-02-12T09:17:14Z")

</div>

Hi everyone,

I have simple table in the vision.

 ![table](https://us1.discourse-cdn.com/inductiveautomation/original/3X/c/9/c9914736baba394768d127a79b15dddf5bebb817.png)

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

---

<div class="post-metadata">

**Author:** ![victordcq](https://avatars.discourse-cdn.com/v4/letter/v/f6c823/32.png) [@victordcq](https://forum.inductiveautomation.com/u/victordcq)\
**Post date:** [February 12, 2024, 9:47am UTC](https://forum.inductiveautomation.com/t/export-to-csv-every-hour/85545/2 "2024-02-12T09:47:07Z")

</div>

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](https://docs.inductiveautomation.com/display/DOC81/Gateway+Event+Scripts#GatewayEventScripts-TimerScripts)

---

<div class="post-metadata">

**Author:** ![Molnar\_Bence](https://avatars.discourse-cdn.com/v4/letter/m/c68b51/32.png) [@Molnar\_Bence](https://forum.inductiveautomation.com/u/Molnar_Bence)\
**Post date:** [February 12, 2024, 11:11am UTC](https://forum.inductiveautomation.com/t/export-to-csv-every-hour/85545/3 "2024-02-12T11:11:33Z")

</div>

> [@victordcq](#):
>
> Dont point to the table though, make the same query your tables uses, but here

Thank you the answer!!

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

 ![code](https://us1.discourse-cdn.com/inductiveautomation/original/3X/e/9/e95573b4385db256b8d5d10256cfd497f551720c.png)

And here is the problem:  
 ![event](https://us1.discourse-cdn.com/inductiveautomation/original/3X/9/f/9f9b57f6a6013ffb9f435faf17bd80cb90d2701a.png)

Do you have idea what is the problem?

Thank you!

---

<div class="post-metadata">

**Author:** ![Matrix\_Engineering](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/matrix_engineering/32/19781_2.png) [@Matrix\_Engineering](https://forum.inductiveautomation.com/u/Matrix_Engineering)\
**Post date:** [February 12, 2024, 12:16pm UTC](https://forum.inductiveautomation.com/t/export-to-csv-every-hour/85545/4 "2024-02-12T12:16:51Z")

</div>

> [@victordcq](#):
>
> Dont point to the table though

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

---

<div class="post-metadata">

**Author:** ![victordcq](https://avatars.discourse-cdn.com/v4/letter/v/f6c823/32.png) [@victordcq](https://forum.inductiveautomation.com/u/victordcq)\
**Post date:** [February 12, 2024, 12:26pm UTC](https://forum.inductiveautomation.com/t/export-to-csv-every-hour/85545/5 "2024-02-12T12:26:15Z")

</div>

> [@victordcq](#):
>
> Dont point to the table though, make the same query your tables uses

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

---

<div class="post-metadata">

**Author:** ![bkarabinchak.psi](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bkarabinchak.psi/32/83567_2.png) [@bkarabinchak.psi](https://forum.inductiveautomation.com/u/bkarabinchak.psi)\
**Post date:** [February 12, 2024, 12:30pm UTC](https://forum.inductiveautomation.com/t/export-to-csv-every-hour/85545/6 "2024-02-12T12:30:27Z")

</div>

Not the point of this post but I highly recommend you get used to using [https://docs.inductiveautomation.com/display/DOC81/system.date](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.

---

<div class="post-metadata">

**Author:** ![Molnar\_Bence](https://avatars.discourse-cdn.com/v4/letter/m/c68b51/32.png) [@Molnar\_Bence](https://forum.inductiveautomation.com/u/Molnar_Bence)\
**Post date:** [February 12, 2024, 12:33pm UTC](https://forum.inductiveautomation.com/t/export-to-csv-every-hour/85545/7 "2024-02-12T12:33:22Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Matrix\_Engineering](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/matrix_engineering/32/19781_2.png) [@Matrix\_Engineering](https://forum.inductiveautomation.com/u/Matrix_Engineering)\
**Post date:** [February 12, 2024, 12:45pm UTC](https://forum.inductiveautomation.com/t/export-to-csv-every-hour/85545/8 "2024-02-12T12:45:03Z")

</div>

Then use this:

[https://docs.inductiveautomation.com/display/DOC81/system.tag.readBlocking](https://docs.inductiveautomation.com/display/DOC81/system.tag.readBlocking)

And write the results to the CSV

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [February 12, 2024, 4:30pm UTC](https://forum.inductiveautomation.com/t/export-to-csv-every-hour/85545/9 "2024-02-12T16:30:40Z")

</div>

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.
