Я загружаю данные из опроса, который мы провели в Qualtrics.Я нашел пример кода Python 3 (https://api.qualtrics.com/docs/response-exports) и основал свой код на нем.
После успешной загрузки я заметил, что вопросы, которые предоставили пользователю возможность выбора из списка, были загружены в виде чисел(Я подозреваю, что индекс выбранного ответа).
Я полагаю, что ответ прост, если ввести некоторые параметры для загрузки данных по-другому, но я не могу найти его в документации API Qualtric.
Вот как выглядят данные, когда я использую эту программу
Вот как я хочу, чтобы она выглядела
Вотмой код с учетными данными API изменился:
import shutil
import os
import requests
import zipfile
import json
import io
# Setting user Parameters
apiToken = "myKey"
surveyId = "mySurveyID"
fileFormat = "csv"
dataCenter = "az1"
# Setting static parameters
requestCheckProgress = 0
progressStatus = "in progress"
baseUrl = "https://{0}.qualtrics.com/API/v3/responseexports/".format(dataCenter)
headers = {
"content-type": "application/json",
"x-api-token": apiToken,
}
# Step 1: Creating Data Export
downloadRequestUrl = baseUrl
downloadRequestPayload = '{"format":"' + fileFormat + '","surveyId":"' + surveyId + '"}'
downloadRequestResponse = requests.request("POST", downloadRequestUrl, data=downloadRequestPayload, headers=headers)
progressId = downloadRequestResponse.json()["result"]["id"]
print(downloadRequestResponse.text)
#print (requests)
# Step 2: Checking on Data Export Progress and waiting until export is ready
while requestCheckProgress < 100 and progressStatus is not "complete":
requestCheckUrl = baseUrl + progressId
requestCheckResponse = requests.request("GET", requestCheckUrl, headers=headers)
requestCheckProgress = requestCheckResponse.json()["result"]["percentComplete"]
print("Download is " + str(requestCheckProgress) + " complete")
# Step 3: Downloading file
requestDownloadUrl = baseUrl + progressId + '/file'
requestDownload = requests.request("GET", requestDownloadUrl, headers=headers, stream=True)
# Step 4: Unzipping the file
zipfile.ZipFile(io.BytesIO(requestDownload.content)).extractall("MyQualtricsDownload")
# Step 5: Move the file out of the folder and place it in the working directory --> change the paths to the appropiate paths for the server
shutil.move( "/Users/Abram/Documents/PCC/MyQualtricsDownload/Mindshare English v21.csv", "/Users/Abram/Documents/PCC/Mindshare English v21.csv")
os.rmdir("/Users/Abram/Documents/PCC/MyQualtricsDownload/")
print('Complete')
Спасибо :)