Export specific data elements in Excel


Conjointly allows you to export all data at once or export specific data elements individually. This is useful when you only need specific sheets, such as quality risk signals or respondent locations.

Here is how to use R to export specific elements from your experiment as an Excel file.

The example below exports the Respondent Information and Quality risk signals sheets.

CONJOINTLY_TOKEN <- "YOUR_TOKEN" # Get a token from https://run.conjoint.ly/utilities/tokens

formulateElements <- function() {
  elements <- list(
          type = "excel",
          numberFormatPreference = TRUE,
          colnameFormat = "one_row",
          elements = list(
                  list(type = "special-entity", payload = list(what = "respondent-info", mode = "simplified")),
                  list(type = "special-entity", payload = list(what = "data-dumps-quality-risk-signals"))
  ))
  return(elements)
}

downloadExport <- function(experiment_id, overwrite = FALSE, filename = "data.xlsx", elements = formulateElements(), TOKEN = CONJOINTLY_TOKEN) {

  library(httr)
  library(jsonlite)

  headers <- add_headers(
    `Authorization` = paste("Bearer", TOKEN),
    `Content-Type` = "application/json",
    `Accept` = "application/json",
    `X-Requested-With` = "XMLHttpRequest"
  )

  cat('Requesting export of data...\n')
  exportRequest <- POST(
    paste0("https://api.conjoint.ly/api/experiments/", experiment_id, "/export/element"),
    headers,
    body = toJSON(elements, auto_unbox = T)
  ) |> content("parsed", encoding = "UTF-8")

  # Make sure the export is completed:
  repeat {
    if (exportRequest$data$status %in% c('completed', 'done')) {
      break;
    }
    Sys.sleep(2)

    cat('Checking if file is ready...\n')
    exportRequest <- GET(
      paste0("https://api.conjoint.ly/api/jobs/", exportRequest$data$id, "/get"),
      headers
    ) |> content("parsed", encoding = "UTF-8")
  }

  cat('Finding the location of the file on AWS...\n')
  intermediateFilename <- exportRequest$data$response$uri
  awsFileLocationRequest <- GET(
    intermediateFilename,
    headers
  )

  cat('Downloading the file from AWS...\n')
  GET(
    awsFileLocationRequest$url,
    write_disk(filename, overwrite = overwrite)
  )

  return(awsFileLocationRequest$url)
}

downloadExport(experiment_id, overwrite = TRUE)

To customise your export, add or remove items in the elements list inside formulateElements(), and update the what = value with the element you wish to export. Note that only respondent-info accepts an additional mode parameter ("simplified" or "full").

Available elements

  • respondent-info
    • Optional mode: "simplified" or "full"
  • conjoint-data
  • conjoint-ranked-concepts
  • interactive-simulator
  • data-dumps
  • data-dumps-crosstab
  • data-dumps-questions
  • data-dumps-items-of-questions
  • data-dumps-stimuli-in-monadic-blocks
  • data-dumps-answers-to-questions
  • data-dumps-answers-to-questions-items
  • data-dumps-owb
  • data-dumps-twb
  • data-dumps-twb-weights
  • data-dumps-bowb
  • data-dumps-cboh
  • data-dumps-cboh-weights
  • data-dumps-quality-risk-signals
  • data-dumps-respondents-locations
  • data-dumps-text-highlights-raw
  • data-dumps-text-highlights-tabulated
  • data-dumps-image-heatmap-dots
  • data-dumps-image-heatmap-brushes
  • data-dumps-segment-membership
  • data-dumps-design-matrix
  • data-dumps-model-matrix
  • data-dumps-raw-responses
  • data-dumps-conversational-survey-answers