\"\nsurveyId = \"\"\nfileFormat = \"csv\"\ndataCenter = ''\n\n# Setting static parameters\nrequestCheckProgress = 0\nprogressStatus = \"in progress\"\nbaseUrl = \"https://{0}.qualtrics.com/API/v3/responseexports/\".format(dataCenter)\nheaders = {\n \"content-type\": \"application/json\",\n \"x-api-token\": apiToken,\n }\n\n# Step 1: Creating Data Export\ndownloadRequestUrl = baseUrl\ndownloadRequestPayload = '{\"format\":\"' + fileFormat + '\",\"surveyId\":\"' + surveyId + '\"}'\ndownloadRequestResponse = requests.request(\"POST\", downloadRequestUrl, data=downloadRequestPayload, headers=headers)\nprogressId = downloadRequestResponse.json()[\"result\"][\"id\"]\nprint(downloadRequestResponse.text)\n\n# Step 2: Checking on Data Export Progress and waiting until export is ready\nwhile requestCheckProgress < 100 and progressStatus is not \"complete\":\n requestCheckUrl = baseUrl + progressId\n requestCheckResponse = requests.request(\"GET\", requestCheckUrl, headers=headers)\n requestCheckProgress = requestCheckResponse.json()[\"result\"][\"percentComplete\"]\n print(\"Download is \" + str(requestCheckProgress) + \" complete\")\n\n# Step 3: Downloading file\nrequestDownloadUrl = baseUrl + progressId + '/file'\nrequestDownload = requests.request(\"GET\", requestDownloadUrl, headers=headers, stream=True)\n\n# Step 4: Unzipping the file\nzipfile.ZipFile(io.BytesIO(requestDownload.content)).extractall(\"/MyQualtricsDownload\")\nprint('Complete')"},{"cell_type":"code","execution_count":null,"metadata":{"trusted":true},"outputs":[],"source":""}],"metadata":{"kernelspec":{"display_name":"Python 3","language":"python","name":"python3"},"language_info":{"codemirror_mode":{"name":"ipython","version":3},"file_extension":".py","mimetype":"text/x-python","name":"python","nbconvert_exporter":"python","pygments_lexer":"ipython3","version":"3.6.0"}},"nbformat":4,"nbformat_minor":2}]]>
9145fc4a7ff244c48724db3bc320dcf6
51895
8d04f218-dc13-4e81-9308-19a9cb9ebe6b
1
Horizontal
QualtricsAPI_PythonTool_PublicTemplate