I am trying to collect means and standard deviations of reaction times from my data files, created using PsychoPy. However, when I first try to split a line from the file with line.split(’,’), I get the error saying there are too many values to unpack. If I then implement some of the solutions I have seen online e.g. putting the values into a for loop -> for (trialnum, rt) in line.split(’,’): <- I get another error that says ‘need more than 1 value to unpack’. Please could someone help me fix this!
my code:
import glob, os
#prints file name in Data folder in order (ppt1-ppt20)
os.chdir("/Users/ameliashelton/Documents/Year 3 /Programming in Neuroimaging/Assessment 2/data")
rts = []
for file in sorted(glob.glob("*.csv")):
f = open (file, 'r')
f.readline()
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 : {:.2f}seconds".format(rt_mean))
print("RT Std : {:.2f}seconds".format(rt_std))
print("Num RTs : {}".format(rt_ntrials)) ```