diff --git a/DESCRIPTION b/DESCRIPTION index a20f379..fecc8cf 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -25,6 +25,7 @@ URL: https://docs.ropensci.org/qualtRics/, https://github.com/ropensci/qualtRics BugReports: https://github.com/ropensci/qualtRics/issues Imports: + archive, cli, dplyr (>= 1.0), fs, diff --git a/NEWS.md b/NEWS.md index 7704ccf..6b0ba36 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,6 +1,7 @@ # qualtRics (development version) - Fixed bug when a survey question has *both* recoded values and variable naming thanks to @Haunfelder (#343) +- Changed how CSV files are extracted from the Qualtrics zip archive, to handle special characters in survey titles (#349) # qualtRics 3.2.0 diff --git a/R/fetch_survey.R b/R/fetch_survey.R index b85aa91..7c2988f 100644 --- a/R/fetch_survey.R +++ b/R/fetch_survey.R @@ -480,9 +480,7 @@ export_responses_progress <- #' @importFrom utils unzip #' @keywords internal export_responses_filedownload <- - function(surveyID, - fileID, - tmp_dir){ + function(surveyID, fileID, tmp_dir){ # Clean up zip file (for security) zip_path <- fs::file_temp(ext = "zip", tmp_dir = tmp_dir) @@ -524,28 +522,19 @@ export_responses_filedownload <- ) } - - # Make connection to zip file: - zipcon <- - unz( - description = zip_path, - filename = csv_filename, - open = "rb" - ) + # Extract CSV from zip file: + archive::archive_extract(zip_path, tmp_dir, csv_filename) # Read in raw data: rawdata <- suppressMessages( readr::read_csv( - file = zipcon, + file = fs::path(tmp_dir, csv_filename), col_types = readr::cols(.default = readr::col_character()), na = c("") ) ) - # Close connection: - close(zipcon) - # Return raw data: return(rawdata) }