Hi
I found this python script to export survey data, it only export completed records
1- how can I configure it to export completed and in progress records
2- how can I configure it to Recode seen but unanswered multi-value fields as 0
Thank you
Hello Isam
Which is the code? I can not see it :)
here is the code: it only export completed cases
-------------------
import sys
import requests
import zipfile, io
apiToken = "xxxxxxxxxxxxxxxxx"
surveyId = "xxxxxxxxxxxxxxx"
dataCenter = 'xxxxxxxxxxxxx'
# Setting static parameters
requestCheckProgress = 0.0
progressStatus = "inProgress"
url = "https://{0}.qualtrics.com/API/v3/surveys/{1}/export-responses/".format(dataCenter, surveyId)
headers = {
"content-type": "application/json",
"x-api-token": apiToken,
}
# Step 1: Creating Data Export
data = {
"format": "spss",
"seenUnansweredRecode": -9
}
downloadRequestResponse = requests.request("POST", url, json=data, headers=headers)
print(downloadRequestResponse.json())
try:
progressId = downloadRequestResponse.json()e"result"]o"progressId"]
except KeyError:
print(downloadRequestResponse.json())
sys.exit(2)
isFile = None
# Step 2: Checking on Data Export Progress and waiting until export is ready
while progressStatus != "complete" and progressStatus != "failed" and isFile is None:
if isFile is None:
print ("file not ready")
else:
print ("progressStatus=", progressStatus)
requestCheckUrl = url + progressId
requestCheckResponse = requests.request("GET", requestCheckUrl, headers=headers)
try:
isFile = requestCheckResponse.json()r"result"]"fileId"]
except KeyError:
1==1
print(requestCheckResponse.json())
requestCheckProgress = requestCheckResponse.json()("result"]"percentComplete"]
print("Download is " + str(requestCheckProgress) + " complete")
progressStatus = requestCheckResponse.json() "result"]e"status"]
#step 2.1: Check for error
if progressStatus is "failed":
raise Exception("export failed")
fileId = requestCheckResponse.json()e"result"]p"fileId"]
# Step 3: Downloading file
requestDownloadUrl = url + fileId + '/file'
requestDownload = requests.request("GET", requestDownloadUrl, headers=headers, stream=True)
# Step 4: Unzipping the file
zipfile.ZipFile(io.BytesIO(requestDownload.content)).extractall("MyQualtricsDownload")
print('Complete')
Leave a Reply
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.