| Reference | Downloads | Github

How to save experiment data in a particular format

The default data output format is very messy and records everything. How can I make the data output presents itself in a particular format? (Like only save the type of information I want for each trial. Each trial info and result are in one row.)

There are benefits to saving so much information, in that you may find you need it in the future. If you want to create a new file with filtered data, you can easily do this using code e.g., :slight_smile:

import pandas as pd
# Open data, with columns A to Z
dat = pd.read_csv("my_data.csv")
# Save only columns A and J
newData = dat[["columnA", "columnJ"]]

Thanks! How about for the online part (javascript)?

This is a post processing step, so you can download all of your files, and iterate over your list of files and make the changes. To extend the example to a folder full of data files, you would put this code in a script, save it to the directory containing your files and run it:

import glob
import pandas as pd

# Find all csv files in current folder
fileList = glob.glob("*.csv")

# Iterate through files
for currentFile in fileList:
    dat = pd.read_csv(currentFile)
    # Get columns A and J
    newData = dat[["columnA", "columnJ"]]
    # Get fileName for saving
    newFileName = currentFile.split(".csv")[0]
    # Save new file
    newData.to_csv(newFileName + "processed" + ".csv")    

Thank you! By the way, my feedback message isn’t working on Pavlovia (on the builder it works perfectly fine).

My python code for feedback message is:

if not key_resp.rt:
msg= ‘Failed to respond’
elif key_resp.keys[-1]==corrAns:
msg = ‘Correct!’
msg= ‘Wrong!’

my corresponding js (which isn’t working online) is:

if (key_resp.rt == undefined) {
msg= ‘Failed to respond’;
} else if (key_resp.corr == 1) {
msg= ‘Correct!’;
} else {
msg= ‘Wrong!’;

I don’t know which part is wrong

That code looks ok to me, would you mind sharing your URL to the task?

Here’s the gitlab link (mine is still in pilot state) and here’s the file, in case if you have any problem opening the link. Thank you!

testing to del.psyexp (21.4 KB)