Themistra
Themistra
Guide

Open your data in R, Python or SPSS

For researchers with responses to analyse. How the CSV exports are laid out, how to load them without the header lines and the descriptions row, how to join them, select by question ID and reshape to one row per participant and question.

This is the how-to. The column-by-column reference, with sample files, is What's in your data, and it isn't repeated here.

  1. 1

    Download the files from Results

    Open Results, pick the survey, and use the download box:

    • Download answers (CSV): one row per participant with the answers. Always there.
    • Download timing (CSV): time per question, and the folder order when folders swap places. It carries the Pro badge: the timing file is part of the Professional plan; during the beta it is free on every plan (the badge reads “Pro · Free in Beta”).
    • Download audio (CSV): only shown when the survey has an audio clip, or has playback recorded for one that has since been removed. It has no plan label.

    The buttons are greyed out until there is a response. Responses from preview (your own test runs) are left out of the files. A file is named after the survey, the kind and the download date, for example My study-answers-2026-11-09.csv, and holds the responses as they were at the moment you pressed the button. Every column is described in What's in your data, with sample files you can try the snippets on.

  2. 2

    Know the file layout

    All three files are laid out the same way:

    1. Lines 1 and 2: survey_id and survey_title, each with its value. They are written once, not on every row.
    2. Lines 3 and 4: blank.
    3. Line 5: the column names. This is the header of the table.
    4. Line 6: what each column holds, in plain words. It is a row of text, not data: leave it out when you load the table.
    5. From line 7: one row per response, oldest first.

    So 4 lines come before the header, and the descriptions row comes right after it. The survey title is typed in a single-line field, so those 4 lines stay 4 lines (a title with a comma is quoted, which is no problem for a CSV reader).

    How the cells are written:

    • Encoding and separators. UTF-8 with a byte-order mark at the very start of the file, so Excel shows non-Latin text correctly. It sits in line 1, which you skip, but tell your reader the file is UTF-8 (utf-8-sig or UTF-8-BOM) so the mark doesn't end up in a name. Comma between cells, double quote around a cell that contains a comma, a quote or a line break (a quote inside is doubled). Rows end with a line feed. A text answer or comment with a line break therefore takes more than one line, so read the table with a CSV reader rather than by splitting lines.
    • Dates and times. submitted_at is ISO 8601 text in UTC, from the server's clock, for example 2026-11-03T09:15:57.400Z. started_at, in the answers file, is the same format from the participant's own device clock. Both are text until you parse them. Durations are plain numbers of seconds with one decimal (103.8); columns ending in _ms are milliseconds.
    • Numbers. Scale and VAS answers are plain numbers. A whole column is numeric only if every cell in it is: one text answer makes your reader treat it as text.
    • Several values in one cell. Multiple-choice selections and rankings are joined with a comma and a space, Option A, Option C (a ranking lists the options best first), so the cell is quoted in the file. If an option's own text contains a comma and a space, you can't split it apart safely. A matrix answer is Row 1: 4, Row 2: 2, rows in the order of the question, only rows that were rated. Yes / No questions read Yes or No, consent questions Approved or Declined. Text answers are trimmed.
    • Empty cells mean no data: the question wasn't answered or wasn't shown, or the measure was recorded only from a later date (the descriptions say from when). The file can't tell a skipped question from one that was never shown. Blank is not zero.
    • A leading apostrophe. A text cell that starts with =, +, - or @ (or a tab or carriage return), and isn't a plain number, is written with a ' in front, so Excel and Sheets show it as text instead of running it as a formula. Negative numbers are left alone. Your reader keeps the apostrophe: read_export in step 4 takes it off. It can't tell one Themistra wrote from one a participant typed themselves in front of such a character, so that one is taken off too.
  3. 3

    Know what response_id is

    The first two columns of every file are response_id and submitted_at. A response has the same response_id in the answers, timing and audio files as long as you download them from the same set of responses, so that is the key for joining them. Use both columns as the key, and check that every row matched: if a response was deleted between two downloads, the numbers shift and rows stop matching.

    Take care of what response_id is. It is not stored with the response. Each export sorts the responses oldest first by submission time and writes response_1, response_2 and so on, so it is a position in that list, the same number as the response's number in the By Survey view of Results. Responses already there keep their number when new ones come in, because new ones are later. But if you delete a response, every later one moves up by one. Treat it as a label for one set of downloads:

    • Download the files you want to join in the same sitting, and join them right away.
    • Don't save a response_id from one day and look it up in a file from another. To follow a participant across downloads, use their ID from the link (for example prolific_pid), if you set up Read participant IDs from the link before collecting, or submitted_at, which is stored with the response and the same in every file.
    • response_id is text (response_10 sorts before response_2 as text). Sort on submitted_at if you need the order.
  4. 4

    Load a file

    The snippets use answers.csv: rename your download, or put its real name in the path. Each skips the same lines: the 4 survey-header lines and the descriptions row. Empty cells become missing values, and nothing else does (so a text answer of “NA” stays text). Link-parameter columns hold IDs: list yours in ID_COLUMNS (Python) or text_cols (R) so they are read as text. Otherwise an ID like 000123 or 5e1200000000000000000001 is turned into a number. The function also takes off the leading apostrophe described in step 2.

    Python (pandas)

    import pandas as pd
    
    ID_COLUMNS = ["prolific_pid", "study_id", "session_id"]   # your link parameters, in lower case
    
    def read_export(path):
        # Lines 1-4: survey header. Line 5: column names. Line 6: descriptions (skipped).
        df = pd.read_csv(path, skiprows=[0, 1, 2, 3, 5], encoding="utf-8-sig",
                         keep_default_na=False, na_values=[""],
                         dtype={c: "string" for c in ID_COLUMNS})
        # Answers that would have run as spreadsheet formulas start with a ' : take it off.
        for c in df.select_dtypes(exclude="number").columns:
            df[c] = df[c].astype("string").str.replace(r"^'(?=[-=+@\t\r])", "", regex=True)
        return df
    
    answers = read_export("answers.csv")

    skiprows counts from 0: it drops the 4 header lines and the line after the names, and the line left on top becomes the header. The descriptions row, if you want it as a lookup:

    Python: the descriptions

    # The descriptions row, by column name:
    descriptions = pd.read_csv("answers.csv", skiprows=4, nrows=1, encoding="utf-8-sig").iloc[0]

    R (base R)

    read_export <- function(path, text_cols = c("prolific_pid", "study_id", "session_id")) {
      part <- function(skip, nrows = -1, colClasses = NA) {
        read.csv(path, skip = skip, nrows = nrows, header = FALSE, na.strings = "",
                 colClasses = colClasses, fileEncoding = "UTF-8-BOM", stringsAsFactors = FALSE)
      }
      # Lines 1-4: survey header. Line 5: column names. Line 6: descriptions. Data from line 7.
      col_names <- unlist(part(skip = 4, nrows = 1, colClasses = "character"), use.names = FALSE)
      data <- part(skip = 6, colClasses = ifelse(col_names %in% text_cols, "character", NA))
      names(data) <- col_names
      is_text <- vapply(data, is.character, logical(1))
      data[is_text] <- lapply(data[is_text], function(x) sub("^'(?=[-=+@\t\r])", "", x, perl = TRUE))
      data
    }
    
    answers <- read_export("answers.csv")

    In R, skip counts lines from 1: the data is read from line 7, and the names from line 5. This is plain read.csv, with no packages. If you prefer readr, read from line 7 the same way and take the names from line 5.

    SPSS

    File → Import Data → Text Data, then in the wizard: encoding Unicode (UTF-8), delimited, variable names at the top of the file, on line 5, first case of data on line 7, comma as the only delimiter, double quote as the text qualifier. Scan all cases to set the variable formats. In syntax, use the wizard's Paste button: it writes GET DATA /TYPE=TXT /FILE='answers.csv' /ENCODING='UTF8' /ARRANGEMENT=DELIMITED /DELCASE=LINE /FIRSTCASE=7 /DELIMITERS="," /QUALIFIER='"' /VARIABLES=… with every column listed (GET DATA can't read the names from line 5). Check the first case after the import: it should be response_1, not the descriptions.

    The per-question columns have long names with spaces, brackets and full stops, which SPSS renames to names it accepts. To choose the names yourself, load and rename in Python or R as in the next steps, then write a clean copy and import that one: its names are on line 1 and its first case on line 2. SPSS's text import may split a cell that contains a line break, so the copy replaces line breaks in text answers and comments with spaces. After the import, check that the number of cases equals the number of responses.

    Python: a clean copy for SPSS

    # For SPSS: line breaks inside text answers become spaces, so each response stays one line.
    clean = answers.replace({r"[\r\n]+": " "}, regex=True)
    clean.to_csv("answers-clean.csv", index=False, encoding="utf-8-sig")
    print(len(clean), "responses")

    R: a clean copy for SPSS

    # For SPSS: line breaks inside text answers become spaces, so each response stays one line.
    clean <- answers
    is_text <- vapply(clean, is.character, logical(1))
    clean[is_text] <- lapply(clean[is_text], function(x) gsub("[\r\n]+", " ", x))
    write.csv(clean, "answers-clean.csv", row.names = FALSE, na = "", fileEncoding = "UTF-8")
    nrow(clean)   # should equal the number of responses

    Don't open this copy in Excel or Sheets: it has lost the leading apostrophe, so answers that start with = run as formulas there.

    Themistra doesn't export a .sav file. To get one, save from SPSS after the import, or write one from R or Python with a package that does (for example haven or pyreadstat).

  5. 5

    Pick columns by question ID

    Per-question columns are named Q{n}. {question name} [{id}] - answer: the question's number, its text, its ID in square brackets, then the field (answer, comment, shown_order, and in the timing file view_seconds and others). The number and text change when you move or reword the question; the ID doesn't, and it is the same in all three files. So select and join on the ID, not on the text. The ID is the last bracket before the field, so brackets in the question text do no harm. The number counts Instructions items too (they have no answer columns), so it can be higher than the number participants saw.

    Python

    import re
    
    COLUMN = re.compile(r"^Q\d+\. .*\[([^\[\]]+)\] - ([a-z_]+)$")
    
    # Pick a question's columns by its [id]:
    pleasant = [c for c in answers.columns if "[q_pleasant] - " in c]
    
    # Or rename every per-question column to "<id>_<field>", e.g. q_pleasant_answer:
    def short_name(column):
        m = COLUMN.match(column)
        return f"{m[1]}_{m[2]}" if m else column
    
    answers = answers.rename(columns=short_name)

    R

    # Pick a question's columns by its [id]:
    pleasant <- grep("[q_pleasant] - ", names(answers), fixed = TRUE, value = TRUE)
    
    # Or rename every per-question column to "<id>_<field>", e.g. q_pleasant_answer:
    short_names <- function(x) sub("^Q[0-9]+\\. .*\\[([^\\[\\]]+)\\] - ([a-z_]+)$", "\\1_\\2", x, perl = TRUE)
    names(answers) <- short_names(names(answers))

    After the rename, q_pleasant_answer is a name you can type. Columns without a question ID in the name (response_id, submitted_at, the timing file's total, link parameters, device columns) keep their names.

  6. 6

    Join answers and timing

    One row per participant, with the answers and the timing side by side. Rename the timing file the same way as the answers file, join on both key columns, and stop if any row has no match. Both files have a shown_order column per question when anything shuffles, so the join gives them suffixes:

    Python

    # Rename the timing file the same way, then join on both key columns.
    timing = read_export("timing.csv").rename(columns=short_name)
    both = answers.merge(timing, on=["response_id", "submitted_at"], how="outer",
                         suffixes=("_answers", "_timing"), validate="one_to_one", indicator=True)
    assert (both["_merge"] == "both").all(), "rows don't match: download both files again, together"
    both = both.drop(columns="_merge").sort_values("submitted_at", ignore_index=True)   # back to oldest first

    R

    # Rename the timing file the same way, then join on both key columns.
    timing <- read_export("timing.csv")
    names(timing) <- short_names(names(timing))
    both <- merge(answers, timing, by = c("response_id", "submitted_at"), all = TRUE,
                  suffixes = c(".answers", ".timing"))
    stopifnot(nrow(both) == nrow(answers), nrow(both) == nrow(timing))   # every row matched
    # merge() sorts by the key, as text: response_10 comes before response_2.

    The audio file joins the same way. Its columns are in the listening test guide: Run an online listening test.

  7. 7

    Reshape to one row per participant and question

    The files are wide: one row per participant, a few columns per question. Mixed models and most plots want the long form. There is no long export from Themistra yet, so reshape it. This turns the answers file and the timing file into one row per participant and question, with the answer, its position and the time on screen:

    Python (pandas)

    import re
    import pandas as pd
    
    COLUMN = re.compile(r"^Q\d+\. .*\[([^\[\]]+)\] - ([a-z_]+)$")
    KEY = ["response_id", "submitted_at"]
    
    def to_long(df):
        """One row per participant x question, one column per field (answer, shown_order, comment...)."""
        keep = {c: m.groups() for c in df.columns if (m := COLUMN.match(c))}
        long = df.melt(id_vars=KEY, value_vars=list(keep), var_name="column")
        long[["question_id", "field"]] = [keep[c] for c in long["column"]]
        return (long.pivot(index=KEY + ["question_id"], columns="field", values="value")
                    .rename_axis(columns=None).reset_index())
    
    answers = read_export("answers.csv")   # read_export as above, before any renaming
    timing = read_export("timing.csv")
    tidy = to_long(answers).merge(
        to_long(timing)[KEY + ["question_id", "view_seconds"]],
        on=KEY + ["question_id"], how="left", validate="one_to_one", indicator=True)
    assert (tidy["_merge"] == "both").all(), "rows don't match: download both files again, together"
    tidy = tidy.drop(columns="_merge").sort_values("submitted_at", kind="stable", ignore_index=True)   # oldest first

    In R, the same shape with tidyr, from the file as read in step 4 (before any renaming):

    R (tidyr)

    library(tidyr)
    
    pattern <- "^Q[0-9]+\\. .*\\[([^\\[\\]]+)\\] - ([a-z_]+)$"
    key <- c("response_id", "submitted_at")
    
    to_long <- function(df) {   # df as read by read_export, before any renaming
      q_cols <- grep(pattern, names(df), perl = TRUE, value = TRUE)
      df <- df[c(key, q_cols)]
      df[q_cols] <- lapply(df[q_cols], as.character)   # one type for every question
      pivot_longer(df, cols = all_of(q_cols), names_to = c("question_id", ".value"), names_pattern = pattern)
    }
    
    answers <- read_export("answers.csv")
    timing <- read_export("timing.csv")
    stopifnot(setequal(paste(answers$response_id, answers$submitted_at),
                       paste(timing$response_id, timing$submitted_at)))   # same responses in both files
    long <- merge(to_long(answers), to_long(timing)[c(key, "question_id", "view_seconds")],
                  by = c(key, "question_id"), all.x = TRUE)

    The answer column holds text for every question type, because a column in the long form can't be a number for one question and text for the next. Convert per question: for a scale or VAS, pd.to_numeric in pandas or as.numeric in R. A blank answer is a question the participant didn't answer or wasn't shown.

  8. 8

    Check order effects

    When a folder shuffles, or folders swap places (see Randomize and counterbalance your study), the files carry the order each participant got:

    • shown_order, per question, in the answers and timing files: the question's position among the answers stored for that participant, counted from 1. A question the participant skipped is not stored, so the ones after it count one lower. The column is there only when something shuffles, so a survey without randomization has no such columns.
    • folder_order, in the timing file: the names of the folders that swap places, in the order this participant saw them, separated by |. It is there only when two or more folders swap. In pandas, df["folder_order"].str.split("|") gives the list for each participant, and value_counts() on the column shows how many got each order.

    On the long table from the last step, the rating by position:

    Python

    tidy["rating"] = pd.to_numeric(tidy["answer"], errors="coerce")
    tidy["position"] = pd.to_numeric(tidy["shown_order"], errors="coerce")
    
    # Questions rated on the same scale only, e.g. the clips of one block:
    clips = tidy[tidy["question_id"].isin(["q_pleasant", "q_familiar"])]
    print(clips.groupby("position")["rating"].agg(["count", "mean"]))

    Only compare questions rated on the same scale, so filter on question_id first. A question's position inside a folder is random, not balanced, so group sizes can differ. The order of folders that swap places is balanced: each order comes up equally often across submitted responses (a participant whose order couldn't be fetched got a random one).

What this does not do

  • CSV only: no SPSS .sav, Excel workbook or JSON export.
  • No long (tidy) export: you reshape the wide files yourself, as in step 7. A long export, a raw event log as JSON and a codebook are planned, not built (see Data).
  • No codebook file. The descriptions row of each file describes its columns, but the files don't hold the survey itself: no question types, option lists, scale ends or the condition behind a folder. Keep the survey as it was at collection yourself, for example by saving a copy of it.
  • No stable response ID: response_id is a position in one download, and deleting a response renumbers the ones after it (step 3).
  • Multiple-choice and ranking answers are one text cell, not one column per option, and a matrix answer is one text cell for all its rows.
  • A blank cell can't tell a skipped question from one that was never shown, and shown_order counts only stored answers.
  • Timing is per question, not per event: there is no export of the answer-by-answer event log. See Timing.
  • Link-parameter IDs (000123, 5e12…) become numbers unless you read them as text, as read_export does for the columns you list.
  • SPSS's text import may split a cell that contains a line break, and the clean copy loses the formula protection: don't open it in a spreadsheet.
  • The pandas snippets are run against files the export code writes, in our automated tests. The R and SPSS steps use the same line numbers, which are checked there, but the R and SPSS code itself isn't run.

See the files before you commit

Try the snippets on the sample files first: download the sample CSVs.