Different variable names when downloading as SPSS through API | XM Community
Skip to main content

Hi,
I use the qualtrics API to regularly download data from large surveys.
When downloading the data (as spss files) through the API variable names that I have assigned through the survey editor are not appearing in SPSS as i named them and instead are getting 'qualtrics style names' (like A_xx.xx).
When i download the data directly through the export data option on the web portal the names do appear correctly in SPSS.
I am pasting below part of the python code i am running to access the API.
This is a major problem for us, please help!
thanks,
Eli

# Import R61 Parent POST
import time
timestr = time.strftime(" %m %d %Y")
print timestr
import requests
import zipfile
try: import simplejson as json
except ImportError: import json


apiToken = "xxxxxxxxxxxxxxxxxx"
surveyId = "xxxxxxxxxxxxx"
fileFormat = "spss"
dataCenter = 'ca1'

# 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()j"result"]s"id"]
print downloadRequestResponse.text
# 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()s"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: Unziping file
with open("variablenames.zip", "wb") as f:
  for chunk in requestDownload.iter_content(chunk_size=1024):
   f.write(chunk)
zipfile.ZipFile("variablenames.zip").extractall("xxxxx/xxxxx/xxxxx/xxxxx"+timestr)

Be the first to reply!

Leave a Reply