Skip to content

Commit

Permalink
Use archive::archive_extract() (#349)
Browse files Browse the repository at this point in the history
* Use `archive::archive_extract()`

* Update NEWS
  • Loading branch information
juliasilge authored Jul 31, 2024
1 parent 03f4b66 commit 0066d5f
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 15 deletions.
1 change: 1 addition & 0 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -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

Expand Down
19 changes: 4 additions & 15 deletions R/fetch_survey.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
}
Expand Down

0 comments on commit 0066d5f

Please sign in to comment.