Comments (10)
Hi Delkine,
I'm not sure what you mean when you refer to 'the script'. It would help to see it.
Does qualtRics work stand-alone? Or does it fail across the board?
I just tested it with newest version of R and it works for me.
from qualtrics.
Jasper,
#Here is the Script that has worked until last Friday. I've deleted some irrelevant code (API Key, Instructions etc.)
This script is use to Get Survey Responses from Qualtrics API.
Start
Set Working Directory to R Scripts
setwd("c:/Users/del/Dropbox/Polynesian Cultural Center/Shared PCC/Qualtrics Data")
library(qualtRics)
Found a .qualtRics.yml configuration file in c:/Users/del/Dropbox/Polynesian Cultural Center/Shared PCC/Qualtrics Data. Using these credentials.
surveys <- getSurveys()
#Read lastResponseId for the saved value from previous runs.
lastId.rds <-readRDS("lastId.rds")Provide surveys$id (number that is in brackets) with one associated with chosen survey & save_dir location to one of your choosing
mysurvey <- getSurvey(surveyID = surveys$id[9],
-
save_dir = "/users/del/dropbox/Polynesian Cultural Center/Shared PCC/Qualtrics Data/",
-
lastResponseId = lastId.rds,
-
verbose=TRUE,
-
uselabels=FALSE,
-
force_request = TRUE)
#HERE IS THE ERROR
Error in qualtRicsResponseCodes(res, raw = raw) :
Qualtrics API raised a bad request (400) error - Please report this on https://github.com/JasperHG90/qualtRics/issues
#Get new lastResponseId from current download for next iteration
lastId.rds <- tail(mysurvey$ResponseID,1)
#THIS ERROR IS NEW TOO
Error in tail(mysurvey$ResponseID, 1) : object 'mysurvey' not found
#Save new lastResponseId for next iteration
saveRDS(lastId.rds, file = "lastId.rds")File names and locations can be changed to suit your needs.
mysurvey <- readRDS(file = "/Users/del/Dropbox/Polynesian Cultural Center/Shared PCC/Qualtrics Data/SV_1ZVShEVtp6thqkd.rds") # Initial file is output as *.RDS file.
write.csv(mysurvey, file = "/Users/del/Dropbox/Polynesian Cultural Center/Shared PCC/Qualtrics Data/mshare2.df.csv", row.names = FALSE) # RDS file is converted to csv.End
from qualtrics.
Hi Del,
May I ask why you closed this thread? Was your issue solved?
J.
from qualtrics.
Sorry, I didn't intend to close it. It should still be open. Do I need to do something to open it back up again?
from qualtrics.
To me, this looks like an error caused by passing a bad response id .
Try the following:
- try to download your survey without passing the responseId
- if this works, take a random responseId from the survey and use it to download your results again
- check the RDS file in which your responseId is stored. See if it is malformed in any way.
- in any case, if step 2) works out for you try rebooting your script with the new latest responseId
J.
from qualtrics.
from qualtrics.
Hi Del,
Could you let me know if this is still an issue for you?
Thanks.
J.
from qualtrics.
from qualtrics.
Jasper,
I'm still getting inconsistent behavior from this code. I hope you can point me in the right direction. I thought everything was running as planned but then I get an error. I get this error off and on but not consistently.
This code is run from RStudio and is scheduled to run every night automatically.
Code starts below this line.
setwd("c:/users/del/Qualtrics Data")
library(qualtRics)
registerOptions()
surveys <- getSurveys()
#lastid1.rds <-"R_RISFrOdBtIR1kyZ" ## Remove comment marks in col. 1 when running & no lastid has been previously stored in wd.
## Previously stored lastid will be overwritten. Replace value in " " with responseid desired.
## Save lastid1.rds to a file to store initial value and subsequent values for lastResponseId
#saveRDS(lastid1.rds, file="lastid1.rds") ## Remove comment mark in col. 1 when running & no lastid has been previouly stored in wd.
## Read lastResponseId for the saved value from previous runs.
lastId2.rds <-readRDS("c:/users/del/Qualtrics Data/lastId1.rds")
#Comment
At this point I get the following error:
Error in readRDS("c:/users/del/Qualtrics Data/lastId1.rds") :
error reading from connection
#Comment
The file exists on the wd and it has a valid responseID saved in it.
Once this error occurs there are several other errors as code runs as having this value is the needed
## Provide surveys$id (number that is in brackets) with one associated with chosen survey
mysurvey <- getSurvey(surveyID = surveys$id[9],
save_dir = "/users/del/Qualtrics Data/",
lastResponseId = lastId2.rds,
verbose=TRUE,
uselabels=FALSE,
force_request = TRUE)
## Get new lastResponseId from current download for next iteration
lastId1.rds <- tail(mysurvey$ResponseID,1)
## Save new lastResponseId for next iteration
saveRDS(lastId1.rds, file = "c:/users/del/Qualtrics Data/lastId1.rds")
mysurvey <- readRDS(file = "c:/users/del/Qualtrics Data/SV_1ZVShEVtp6thqkd.rds") # Initial file is output as *.RDS file.
write.csv(mysurvey, file = "c:/users/del/Qualtrics Data/mshare2.df.csv", row.names = FALSE) # RDS file is converted to csv.
from qualtrics.
Hi Del,
I want to help you, but as I'm sure you understand, it's close to impossible for me to debug your code from a distance. This is especially true since the error you are experiencing does not occur in my package, but in a generic R function.
First, a couple of things that, in general, are problematic about your code:
- Don't use spaces in folder names, use underscores: "c:/users/del/Qualtrics Data/SV_1ZVShEVtp6thqkd.rds" --> "c:/users/del/Qualtrics_Data/SV_1ZVShEVtp6thqkd.rds"
- Don't use something like '.df.csv' for your filenames. Names that start with '.' are reserved for the operating system and are used to denote file extension. Again, use underscores. --> 'myfile_df.csv'
Now, I don't know about your current setup, but try the following:
- Update R to the latest version. Make sure that you have only 1 version of R installed and that your system uses the latest R version when it runs the script (instead of a legacy version of R). If you're not sure about this, remove R from your computer entirely, download the latest version and install again.
- Download RStudio, open your script and run your code line by line (make sure to change the spaces to the file name).
- Use a different format to save your lastResponseId in. Instead of RDS, you can save it as a csv file, a plain text file, a yml file and so one (although csv would be easiest given that you know how to write and load it).
Hope that helps.
I'm closing this issue because the error is not related to the qualtRics package.
Best,
Jasper.
from qualtrics.
Related Issues (20)
- Issue with fetching surveys HOT 3
- fetch distribution summary information? HOT 2
- error on fetching distribution history (i.e., full list of survey invitees along with distribution status) HOT 3
- `dplyr::case_when()` within `dplyr::mutate()` loses `qualtRics` variable labels HOT 7
- lag / incomplete pull of list_distribution_links() HOT 1
- feature discussion: custom temporary directory HOT 4
- Future look: Funding support from Qualtrics? HOT 2
- fetch_survey error; filename issue? HOT 18
- results from all_surveys() and list_surveys is different HOT 5
- fetch_survey produces "Error: Qualtrics API raised a bad request (400) error" HOT 5
- Overhaul of credentialling system
- Error parsing file: The file does not appear to be a valid survey. Save as qsf - am I doing it wrong? import doesn't work HOT 5
- write_qsf() currently enables only encoding UTF-8 that doesn't handle Hebrew and Arabic HOT 16
- Release qualtRics 3.2.0 HOT 1
- Qualtrics API reported a bad request error (400) HOT 3
- Qualtrics webservice call using R tools HOT 3
- Question/ comment about the documentation HOT 3
- Ordered factor conversion for multiple choice question HOT 2
- read_survey() no longer (or inconsistently) breaks out sets HOT 6
- Error in unz (colon in survey title) HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from qualtrics.