# Experiment not saving data Online, generates empty CSV files

**URL:** <https://discourse.psychopy.org/t/experiment-not-saving-data-online-generates-empty-csv-files/8174>\
**Category:** Online experiments\
**Tags:** data\
**Created:** [June 19, 2019, 12:26pm UTC](https://discourse.psychopy.org/t/experiment-not-saving-data-online-generates-empty-csv-files/8174 "2019-06-19T12:26:30Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![aendrs](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/aendrs/32/5133_2.png) [@aendrs](https://discourse.psychopy.org/u/aendrs)\
**Post date:** [June 19, 2019, 12:26pm UTC](https://discourse.psychopy.org/t/experiment-not-saving-data-online-generates-empty-csv-files/8174/1 "2019-06-19T12:26:30Z")

</div>

URL of experiment:  
[https://pavlovia.org/run/aendrs/dataval\_a/html/](https://pavlovia.org/run/aendrs/dataval_a/html/)

Description of the problem:

My experiment is saving the data properly when run locally, but it is not saving the data online, it gives me empty .CSV files. I have tried to modify different parameters but no luck so far.

Do anyone have experienced the same issue? Could you provide a suggestion?

Thanks in advance

---

<div class="post-metadata">

**Author:** ![dvbridges](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/dvbridges/32/1918_2.png) [@dvbridges](https://discourse.psychopy.org/u/dvbridges)\
**Post date:** [June 19, 2019, 1:23pm UTC](https://discourse.psychopy.org/t/experiment-not-saving-data-online-generates-empty-csv-files/8174/2 "2019-06-19T13:23:08Z")

</div>

Hi, looks like its an issue with the `trials.finished` statement. You are quitting the loop on the first iteration, so the call to save data is not made. We can look at this scenario, but for now add the following to your code component in the `trial` routine:

```auto
trials.finished = true;
psychoJS.experiment.nextEntry(); // save data and move to next row in Excel sheet

```

---

<div class="post-metadata">

**Author:** ![aendrs](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/aendrs/32/5133_2.png) [@aendrs](https://discourse.psychopy.org/u/aendrs)\
**Post date:** [June 19, 2019, 2:51pm UTC](https://discourse.psychopy.org/t/experiment-not-saving-data-online-generates-empty-csv-files/8174/3 "2019-06-19T14:51:18Z")

</div>

Thanks for the answer!  
it seemed to work, now i get proper CSV files but there is an uninteded error.

The ‘key\_resp.keys’ and ‘key\_resp.rt’ columns are shifted by one element. That is, the first trial row is empty and its corresponding key\_resp value is on row 2, and so on until the last trial row. This eliminates one trial since the last one is not saved (and the previous ones are shifted).

Do you think it can be solved?  
Otherwise I will have to shift the key responses when doinig the analysis and just lose one trial. It’s not ideal but it’s better than nothing.  
Thanks again for your help

---

<div class="post-metadata">

**Author:** ![dvbridges](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/dvbridges/32/1918_2.png) [@dvbridges](https://discourse.psychopy.org/u/dvbridges)\
**Post date:** [June 19, 2019, 3:23pm UTC](https://discourse.psychopy.org/t/experiment-not-saving-data-online-generates-empty-csv-files/8174/4 "2019-06-19T15:23:13Z")

</div>

Looks like a simple solution. The problem is that nextEntry is being called before the keyboard can add the data to the experiment handler. If you move your code component to the bottom of the routine so it appears after the keyboard component, this error should go away. By the way, I have made a pull request to fix this error for future users - see GitHub.

---

<div class="post-metadata">

**Author:** ![aendrs](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/aendrs/32/5133_2.png) [@aendrs](https://discourse.psychopy.org/u/aendrs)\
**Post date:** [June 20, 2019, 8:54am UTC](https://discourse.psychopy.org/t/experiment-not-saving-data-online-generates-empty-csv-files/8174/5 "2019-06-20T08:54:36Z")

</div>

This solved the issue, thank you very much for your help!
