Closed stijndelaat closed 3 months ago
Do you have any special characters (":") in the survey title? That was an issue I had and renaming the survey to just characters fixed it.
Can you run the following code, with your survey ID, and tell me the name of your path? If this is a problem with special characters, we should add a fix to change the file name.
fetch_url <- qualtRics:::create_fetch_url(Sys.getenv("QUALTRICS_BASE_URL"), "SV_xxxAqx")
raw_payload <- qualtRics:::create_raw_payload(
label = TRUE,
start_date = NULL,
end_date = NULL,
unanswer_recode = NULL,
include_display_order = NULL,
limit = NULL,
time_zone = NULL,
include_questions = NULL,
breakout_sets = TRUE
)
res <- qualtRics:::qualtrics_api_request("POST", url = fetch_url, body = raw_payload)
requestID <- res$result$progressId
survey.fpath <- qualtRics:::download_qualtrics_export(fetch_url, requestID, verbose = TRUE)
#> | | | 0% | |======================================================================| 100%
survey.fpath
#> [1] "/var/folders/0w/prb4hnss2gn1p7y34qb2stw00000gp/T//RtmpssoJ6N/Cats Can Have a Little Salami.csv"
Created on 2020-10-30 by the reprex package (v0.3.0.9001)
I think it must be a special character issue indeed. I have a ":" in the name of the survey. Also in the link you requested, since that ends with the name ;)
[Edit] I have removed the characters in the name and they were indeed the problem. Thank you for your help, both Rkol8 and juliasilge!
OK, I am going to leave this open for now, in case we can think about renaming the file. This might not work well, since different OSes have different rules and the problem here is outside of R itself.
In the meantime, I definitely recommend not using special characters in your survey titles.
How about using fs::path_sanitize()
to remove unwanted characters from the file name?
library(fs)
filename <- "~/Desktop/my:super?crazy*file|name.csv"
path(path_dir(filename), path_sanitize(path_file(filename), replacement = "_"))
#> /Users/senecad/Desktop/my_super_crazy_file_name.csv
filename2 <- '~/Desktop/my<other>crazy"file_name.csv'
path(path_dir(filename2), path_sanitize(path_file(filename2), replacement = "_"))
#> /Users/senecad/Desktop/my_other_crazy_file_name.csv
@dsen6644 That is a really good idea; if you are up for a PR implementing this, I'll take a look and review. 👍 Taking a dependency on fs might be helpful for other improvements in the future.
I wonder if we could fix this problem by using archive instead of the base R unz()
. 🤔
Thank you for making an R package for Qualtrics. Great idea! I've recently started using it and I am encountering the following error when using the fetch_survey command:
df <- fetch_survey(surveyID = "SV_xxx", label = TRUE)
Error: File [filename].csv does not exist. Please check if you passed the right file path
The all_surveys() command and the survey_questions() command seem to work fine. Hopefully you are able to help me. Thank you in advance