# How to load a csv file in an online experiment

**URL:** <https://discourse.psychopy.org/t/how-to-load-a-csv-file-in-an-online-experiment/35985>\
**Category:** Online experiments\
**Tags:** pavlovia\
**Created:** [August 3, 2023, 11:18am UTC](https://discourse.psychopy.org/t/how-to-load-a-csv-file-in-an-online-experiment/35985 "2023-08-03T11:18:18Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![pavlovs](https://avatars.discourse-cdn.com/v4/letter/p/aeb1de/32.png) [@pavlovs](https://discourse.psychopy.org/u/pavlovs)\
**Post date:** [August 3, 2023, 11:18am UTC](https://discourse.psychopy.org/t/how-to-load-a-csv-file-in-an-online-experiment/35985/1 "2023-08-03T11:18:18Z")

</div>

In my experiments, participants will enter their personal participant code in the beginning of the experiment and based on this code, I want to select their trial list and present it in the following loops as the condition file.  
However, as I want to load the experiment to Pavlovia, I do not know how to read in my csv file (without using panda) that contains a row with the participant code and the respective file name in the same row. I also would like to know how I can select the file name based on the entered participant code from that list.

I would be very thankful if anyone could help.

Thank you so much!

---

<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:** [August 10, 2023, 6:49am UTC](https://discourse.psychopy.org/t/how-to-load-a-csv-file-in-an-online-experiment/35985/2 "2023-08-10T06:49:17Z")

</div>

I can think of four ways to translate a participant code into a filename.

1. Have filenames containing the participant code and use, e.g. `conditionsFile = 'conditions_' + expInfo['participant'] + '.xlsx'`

2. Add a dictionary to the [shelf](https://psychopy.org/online/shelf.html).

3. Use if / elif statements in a Begin Experiment code component.

4. Cycle through a spreadsheet in a loop checking `if expInfo['participant'] == Participant:`

In all cases you will then need to dynamically load the appropriate spreadsheet using a JS code component. I put the following code in Begin Routine of the first routine.

```auto
psychoJS._serverManager.prepareResources([
{ name: (conditionsFile), path: (conditionsFile) }
]);

```
