In your case you would have values for dty = amount and at the end of a trial, you would use the function writerow() to put the latest values in their right place in the spreadsheet. Here are some example lines from a dictionary where I am setting the values for the conditions of an expriments, note that some of these lines have keys where the value is another dictionary - the dictionaries are nested. #d is the name of the dictionary you have createdĬdw = csv.DictWriter(fh,fieldnames = d.keys(),quoting = csv.QUOTE_MINIMAL) For instance: import csv #to use the spreadsheet export Before the first trial you can use a function to write the keys as the column headings of a spreadsheet, and then each trial add lines with the values. ![]() You start somewhere are the beginning of your program to create the dictionary with all the keys you want, and then as the program runs you store the values in the dictionary. If you like writing your own code, and want to learn a bit more Python, look into dictionaries which store things as "key" and "value" pairs. I've tried a few things, but it doesn't seem that I'm close. ![]() I would like to output the following variables into the data file: 'TotalLater', 'TotalNow', and 'amount'. Here is some relevant code: if branch = 1:įeedback = 'You chose $%.2f in two weeks' %(amount)įeedback = 'You did not make a choice. It's almost complete, but I'm trying to output a few variables that I created in a code component into my data file for the experiment, and I haven't been able to figure out how to do that. I'm working in PsychoPy to design an experiment.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |