Search code examples
rqualtrics

Importing Qualtrics survey into R - error extracting zip


I've had success in the past using the qualtRics package in r to import and analyze data. This time, I'm trying to load in two copies of the survey: once with choices as numbers, and once with choices as text (as others have worked on the survey, I can't assume that the numbering is consistent).

Here's my code:

#Grab list of surveys.
survey_list <- qualtRics::all_surveys()

#Define row number from the survey list, to call on later.
survey_num <- which(survey_list$name == "SurveyName")

#Load the questions from the survey into a data set.
questions <- qualtRics::survey_questions(survey_list$id[survey_num])

#Load the survey data with choices as numbers.
survey_data <-
  qualtRics::fetch_survey(survey_list$id[survey_num], 
                          save_dir = "output/",
                          label = FALSE, 
                          convert = FALSE,
                          force_request = TRUE)

#Load the survey data with choices as text.
survey_data_text <-
  qualtRics::fetch_survey(survey_list$id[survey_num],
                          save_dir = "output/",
                          label = TRUE,
                          convert = FALSE,
                          force_request = TRUE)

#Create a column map.
survey_col_map <- qualtRics::extract_colmap(survey_data_text)

The second time I call qualtRics::fetch_survey(), I receive the following error: Error: Error extracting CSV from zip file. Please re-run your query.. Further code fails beacuse it depends on this output. Naturally, I ran rlang::last_error() and rlang::last_trace(), the results of which are here:

<error/rlang_error>
Error extracting CSV from zip file. Please re-run your query.
Backtrace:
 1. qualtRics::fetch_survey(...)
 2. qualtRics:::download_qualtrics_export(fetch_url, requestID, verbose = verbose)
 3. base::tryCatch(...)
 4. base:::tryCatchList(expr, classes, parentenv, handlers)
 5. base:::tryCatchOne(expr, names, parentenv, handlers[[1L]])
 6. value[[3L]](cond)
Run `rlang::last_trace()` to see the full context.

<error/rlang_error>
Error extracting CSV from zip file. Please re-run your query.
Backtrace:
    x
 1. \-qualtRics::fetch_survey(...)
 2.   \-qualtRics:::download_qualtrics_export(fetch_url, requestID, verbose = verbose)
 3.     \-base::tryCatch(...)
 4.       \-base:::tryCatchList(expr, classes, parentenv, handlers)
 5.         \-base:::tryCatchOne(expr, names, parentenv, handlers[[1L]])
 6.           \-value[[3L]](cond)

Sadly, rerunning my query per the feedback doesn't change the outcome. I can find the .zip in question. I thought it might be left on 'read-only', but changing that file attribute doesn't change the outcome. I'm running R with admin privileges, so it should have permission to create/open/modify files (and does so in other contexts).

I'd love to know how I can fetch the same survey in two formats, once with choices as numbers and once with choices as text, in succession. Thank you for your help!

P.S., first stackoverflow post, so please let me know if you need further information. :)


Solution

  • Updating to readr 2.1.0 solved this problem for me.

    This solution was suggested by Julia Silge, here.