Loading data from csv dropping 1 row

OS Windows
PsychoPy version (e.g. 2024.2.4 Py 3.8): v2024.2.4
Standard Standalone Installation? (y/n) Yes
Do you want it to also run online? (y/n) No
What are you trying to achieve?:

I am trying to get all 169 rows of my csv file read in at the start of my experiment so that the data from the variables can be refered to later.

Currently 168 rows are being read in so somehow I am dropping 1 row.

What did you try to make it work?:

I have a load_data componet at the start of my experiement. In that, I have a code component with the following in the Begin Experiment tab:

import pandas as pd

#import the participants data file
data_file = ‘924443_EEG_trivia_ranking.csv’
trivia_df = pd.read_csv(data_file)

#remove empty rows
trivia_df = trivia_df.dropna(subset=[‘thisTrivia’, ‘thisAnswer’, ‘trivia_slider.response’])

#extract the key columns into Python lists
thisTrivia_list = trivia_df[‘thisTrivia’].tolist()
thisAnswer_list = trivia_df[‘thisAnswer’].tolist()
trivia_rating_list = trivia_df[‘trivia_slider.response’].tolist()

#check what’s loaded in the PsychoPy runner window
print(f"Loaded {len(thisTrivia_list)} trivia entries from {data_file}")
print(thisTrivia_list[:3])

The experiment runs. In the runner window I get a confirmation that the csv file has loaded but only 168 rows.

Thank you

Hi Charlotte,

The issue is likely caused by the line that drops rows with missing data in any of the columns ‘thisTrivia’, ‘thisAnswer’, or ‘trivia_slider.response’. This filtering could be removing one row if it contains a missing value in any of those columns.

Hope this helps.