Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use archive::archive_extract() #349

Merged
merged 2 commits into from
Jul 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading