# Save second csv-file

**URL:** <https://discourse.psychopy.org/t/save-second-csv-file/39311>\
**Category:** Builder\
**Tags:** pavlovia\
**Created:** [March 25, 2024, 1:54pm UTC](https://discourse.psychopy.org/t/save-second-csv-file/39311 "2024-03-25T13:54:31Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![feist](https://avatars.discourse-cdn.com/v4/letter/f/cab0a1/32.png) [@feist](https://discourse.psychopy.org/u/feist)\
**Post date:** [March 25, 2024, 1:54pm UTC](https://discourse.psychopy.org/t/save-second-csv-file/39311/1 "2024-03-25T13:54:31Z")

</div>

PsychoPy version: v 2023.2.3

I have an experiment that is offered online via Pavlovia. Some demographic data is collected and used by several people. However, there is one piece of information that should only be accessible to one person for data protection reasons. I would like to create an additional CSV file for this single piece of information and store it there.

I already know how to delete this information from the usual CSV file, but I’m not sure how to create a separate CSV file just for this specific information using PsychoPy builder and code blocks.

I checked this post: [Saving trial data using csv writer - #2 by Michael](https://discourse.psychopy.org/t/saving-trial-data-using-csv-writer/6296/2) but don’t understand the solution.

Thanks

Daniela

---

<div class="post-metadata">

**Author:** ![rebeccahennessy](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/rebeccahennessy/32/40972_2.png) [@rebeccahennessy](https://discourse.psychopy.org/u/rebeccahennessy)\
**Post date:** [March 25, 2024, 4:55pm UTC](https://discourse.psychopy.org/t/save-second-csv-file/39311/2 "2024-03-25T16:55:49Z")

</div>

Hi! You’ll want to use pandas for this - in “Before Experiment” you’ll add

> import pandas as pd

The rest of this should be in a code component at the end of the experiment (such as a thank you/ending routine) in “Begin Routine”. If you haven’t already, create a variable of the sensitive info you need

> info = #whatever info you’re getting from the experiment

From there, you’ll create a dataframe and export it to a csv

> infoDF = pd.DataFrame(info)  
> infoDF.to\_csv(expInfo[‘participant’]+‘Information.csv’, index = False, header = False)
> 
> # creates a csv titled “999Info.csv”

I hope this helps!

---

<div class="post-metadata">

**Author:** ![wakecarter](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/wakecarter/32/5753_2.png) [@wakecarter](https://discourse.psychopy.org/u/wakecarter)\
**Post date:** [March 25, 2024, 5:20pm UTC](https://discourse.psychopy.org/t/save-second-csv-file/39311/3 "2024-03-25T17:20:10Z")

</div>

Pandas won’t work online and I don’t think you can create additional CSV files.

Could you put this information on the Pavlovia shelf instead of into a data file?

Alternatively you might be able to use an embedded survey and delete the survey data from the csv file after it have been created.

How are you deleting the data? Just using something like thisExp.addData(‘Email’,‘’) ?

---

<div class="post-metadata">

**Author:** ![feist](https://avatars.discourse-cdn.com/v4/letter/f/cab0a1/32.png) [@feist](https://discourse.psychopy.org/u/feist)\
**Post date:** [March 25, 2024, 8:18pm UTC](https://discourse.psychopy.org/t/save-second-csv-file/39311/4 "2024-03-25T20:18:13Z")

</div>

> [@wakecarter](#):
>
> thisExp.addData(‘Email’,‘’)

exactly.

> [@wakecarter](#):
>
> on the Pavlovia shelf

What does this mean?

---

<div class="post-metadata">

**Author:** ![wakecarter](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/wakecarter/32/5753_2.png) [@wakecarter](https://discourse.psychopy.org/u/wakecarter)\
**Post date:** [March 25, 2024, 11:28pm UTC](https://discourse.psychopy.org/t/save-second-csv-file/39311/5 "2024-03-25T23:28:12Z")

</div>

The shelf is one of the tabs in your Pavlovia account. It can only be accessed by the owner and can store lists or dictionaries.

[https://www.psychopy.org/online/shelf.html](https://www.psychopy.org/online/shelf.html)

---

<div class="post-metadata">

**Author:** ![feist](https://avatars.discourse-cdn.com/v4/letter/f/cab0a1/32.png) [@feist](https://discourse.psychopy.org/u/feist)\
**Post date:** [March 27, 2024, 8:44pm UTC](https://discourse.psychopy.org/t/save-second-csv-file/39311/6 "2024-03-27T20:44:59Z")

</div>

Thanks. I got it running.

Do I have to add a record myself?

 ![image](https://us1.discourse-cdn.com/flex002/uploads/psychopy/original/3X/7/4/7471b4f9d63623de1728c89e9120a154511ec4fc.png)

or can I do it with a code-element?

> psychoJS.shelf.addIntegerValue({key: [‘participant\_counter’], delta: 1})

I get this error:

> {origin: ‘Shelf.\_updateValue’, context: ‘when updating the value of the INTEGER record associated with key: [“participant\_counter”]’, error: ‘unable to find a record associated with the given key’}

I have different experiments and setting records up myself, is a high error source, if I forget it.

---

<div class="post-metadata">

**Author:** ![feist](https://avatars.discourse-cdn.com/v4/letter/f/cab0a1/32.png) [@feist](https://discourse.psychopy.org/u/feist)\
**Post date:** [March 27, 2024, 8:57pm UTC](https://discourse.psychopy.org/t/save-second-csv-file/39311/7 "2024-03-27T20:57:30Z")

</div>

assuming, I have 100 values in this list. How do I download it efficiently?

---

<div class="post-metadata">

**Author:** ![wakecarter](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/wakecarter/32/5753_2.png) [@wakecarter](https://discourse.psychopy.org/u/wakecarter)\
**Post date:** [March 27, 2024, 10:04pm UTC](https://discourse.psychopy.org/t/save-second-csv-file/39311/8 "2024-03-27T22:04:44Z")

</div>

Either copy and paste the dictionary into some code or Excel, or give the shelf entry designer scope and write a separate PsychoPy experiment that reads it into a data file.

You could do the latter with experiment scope if you had a “password” participant that activated the download code.
