MacOS High Sierra
PsychoPy version 1.90.3 (Builder)
I am trying to export data from one trial to a separate csv file with only two columns of selected data to be used later on in the experiment as stimuli. I first tried using TrialHandler but I wasn’t able to remove certain columns and rows from being saved (e.g. “extraInfo” components at the bottom of the csv).
Then I tried using the csv writer to select for just the two bits of information I wanted to save: “word” (a parameter from my conditions file) and “cue_input” (the key response to that word). I tried creating the file by using writer and appending it by adding rows at the end of each routine.
I currently have a code component with the following:
Begin Routine
import csv
import os.path
with open('~/Desktop/myfile.csv', 'w') as csvfile:
writer = csv.writer(csvfile, delimiter = ',')
End Routine
with open('~/Desktop/myfile.csv', 'a') as csvfile:
writer = csv.writer(csvfile, delimiter = ',')
writer.writerows(zip(word, cue_input))
Currently it’s only creating the blank “myfile.csv” and not appending it at all or adding in any data. I did try putting the last chunk under “Each Frame” which succeeded in writing something into the file, however both the “word” data was only the same letter repeated in each row and the “cue_input” data was missing entries, so I put it back under “End Routine”.
Ideally, I would like myfile.csv to look something like this:
Any help would be greatly appreciated!