# How can I constantly save variables in tables as the program runs?

**URL:** <https://discourse.processing.org/t/how-can-i-constantly-save-variables-in-tables-as-the-program-runs/18160>\
**Category:** Coding Questions\
**Created:** [February 26, 2020, 9:13pm UTC](https://discourse.processing.org/t/how-can-i-constantly-save-variables-in-tables-as-the-program-runs/18160 "2020-02-26T21:13:37Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![abdullahmq](https://avatars.discourse-cdn.com/v4/letter/a/ea5d25/32.png) [@abdullahmq](https://discourse.processing.org/u/abdullahmq)\
**Post date:** [February 26, 2020, 9:13pm UTC](https://discourse.processing.org/t/how-can-i-constantly-save-variables-in-tables-as-the-program-runs/18160/1 "2020-02-26T21:13:37Z")

</div>

Hi, I am using saveTable() function in my code and the problem I am getting is that my table is constantly saved after every 20 seconds but after about 400 rows I start to get rows with only zeros…I am really confused…regarding it …could it be because of the reason that I am not closing the output file by using exit() function in my code

---

<div class="post-metadata">

**Author:** ![josephh](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/josephh/32/210_2.png) [@josephh](https://discourse.processing.org/u/josephh)\
**Post date:** [February 26, 2020, 11:13pm UTC](https://discourse.processing.org/t/how-can-i-constantly-save-variables-in-tables-as-the-program-runs/18160/2 "2020-02-26T23:13:09Z")

</div>

Hi,

Welcome to the comunity! 🙂

Can you show us a bit of code (by using the `</>` button) to show how and when you save your table?

---

<div class="post-metadata">

**Author:** ![abdullahmq](https://avatars.discourse-cdn.com/v4/letter/a/ea5d25/32.png) [@abdullahmq](https://discourse.processing.org/u/abdullahmq)\
**Post date:** [February 27, 2020, 7:39am UTC](https://discourse.processing.org/t/how-can-i-constantly-save-variables-in-tables-as-the-program-runs/18160/3 "2020-02-27T07:39:56Z")

</div>

I have a timer function in the code like this one

```auto
Table table;
double counter=millis();
void timer(){
  if(millis()>counter+10000){ // means after 10 seconds
    saveTable(table,"data/new.csv");
  }
}

```

the program works fine for 4000 entries and after that the proceeding rows only have zeros

---

<div class="post-metadata">

**Author:** ![Chrisir](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/chrisir/32/45_2.png) [@Chrisir](https://discourse.processing.org/u/Chrisir)\
**Post date:** [February 27, 2020, 8:06am UTC](https://discourse.processing.org/t/how-can-i-constantly-save-variables-in-tables-as-the-program-runs/18160/4 "2020-02-27T08:06:42Z")

</div>

You overwrite the table.

You can as well save after 1 minute or so

Try it

Maybe the error is elsewhere in your Sketch
