sp is a tool for parsing Qualtrics data into a format suitable for R.
sp takes Qualtrics data and creates both a CSV and R import script.
-
Install sp with the command
go install github.com/fflewddur/sp/cmd/sp
(you can download Go here if you don't already have it). -
Export your Qualtrics survey as a QSF file (in Qualtrics: Survey → Tools → Import/Export → Export survey).
-
Export your Qualtrics responses as an XML file (in Qualtrics: Data & Analysis → Export & Import → Export data, select XML; ensure 'Use choice text' is selected; optionally, check the two options to recode seen but unanswered questions/fields).
-
Rename both the QSF and XML files to have the same base name (e.g., survey.qsf and survey.xml). Both files need to be in the same folder.
-
Run sp on your survey data with the command
sp <PATH_TO_QSF_FILE>
. For example, if you saved your QSF and XML files to ~/Downloads with the names survey.qsf and survey.xml, you would run the commandsp ~/Downloads/survey.qsf
. sp will read the survey structure from the QSF file and participants' responses from the XML file. It will create two files: a CSV containing participants' responses, and an R script for importing the CSV into R. These files will be created in the same folder as the QSF file and share the same base name (e.g., runningsp ~/Downloads/survey.qsf
will create survey.csv and survey.r in your Downloads folder). -
Import the data into R by running import script sp generated. Continuing the above example, we'd start R and run the command
source("survey.r", encoding = "utf8")
. Qualtrics exports data encoded in UTF-8, but R will default to the value ofgetOption("encoding")
when sourcingsurvey.r
unless you tell it otherwise. -
(Optional) You can edit the generated R script as appropriate. By default it will define a type for each CSV column (logical, factor, integer, etc.) and include factor levels. For questions that allow multiple responses, logical columns for each response will be generated.
To build sp, run go build ./cmd/sp
from the root of the repository.
To run unit tests, use the command go test -race ./libsp
from the root of the repository.
This project is licensed under the MIT License - see the LICENSE.md file for details