I am trying to sort some Stroop data from 20 participants in 20 different .csv files. I need to calculate means and standard deviations for their reaction times, as well as percentage correct, comparing the congruent and incongruent conditions. All of this needs to be put in a table. I am having some trouble with reading the files and saving the correct elements. For example, I ran the below code and it seemed fine, however, my reaction time variable is not right at all. If someone could help with any of the elements I have described, I would be so grateful!
the code:
import glob
import numpy as np
os.chdir('/Users/ameliashelton/Documents/Year 3 /Programming/stroop/data')
path = '/Users/ameliashelton/Documents/Year 3 /Programming/stroop/data'
rts = []
for file in sorted(os.listdir(path)):
print (file)
f = open (file, 'r')
f.readlines()
for line in f.readlines():
trialnum, rt = line.split(',')
rt = float(rt)
rts.append(rt)
rts = np.array(rts)
rt_mean = rts.mean()
rt_std = rts.std()
rt_ntrials = len(rts)
#print in correct format
print("RT Mean : {:.3f}seconds".format(rt_mean))
print("RT Std : {:.3f}seconds".format(rt_std))
print("Num RTs : {}".format(rt_ntrials))
the data file:
the output: