【问题标题】:Google App Script to Qualtrics API: download, unzip, and push CSV to SheetGoogle App Script to Qualtrics API:下载、解压缩并将 CSV 推送到工作表
【发布时间】:2017-02-09 12:41:19
【问题描述】:

我喜欢使用 Google Apps Script 每天自动执行一次:

1) 向 Qualtrics 发出一个返回 ZIP 文件的 API 请求

2) 解压 ZIP 文件

3) 将新出现的 CSV 文件读入 Google 表格

我是编码和集成所有代码以使其工作的相对新手,但可以理解概念和基本语法,并在一些指导下编辑脚本。非常感谢您的帮助!更多注意事项:

步骤 1) Qualtrics API 需要

首先通过Create Response Export创建文件

var settings = {
  "async": true,
  "crossDomain": true,
  "url": "https://uwa.qualtrics.com/API/v3/responseexports",
  "method": "POST",
  "headers": {
    "x-api-token": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
    "surveyid": "SV_1F9ldubC3O1BcUJ",
    "content-": "application/json",
    "content-type": "application/json"
  },
  "processData": false,
  "data": "{\r\n    \"format\": \"csv\",\r\n    \"surveyId\": \"SV_1F9ldubC3O1BcUJ\",\r\n    \"includedQuestionIds\": [],\r\n    \"useLabels\": true\r\n}"
}

$.ajax(settings).done(function (response) {
  console.log(response);
});

然后通过Get Response Export File获取返回的文件ID(例如“ES_e7s2ja08o9o4df6cd7ptckmfma”)下载文件

var settings = {
  "async": true,
  "crossDomain": true,
  "url": "https://uwa.qualtrics.com/API/v3/responseexports/ES_e7s2ja08o9o4df6cd7ptckmfma/file",
  "method": "GET",
  "headers": {
    "x-api-token": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
    "content-type": "application/json"
  }
}

$.ajax(settings).done(function (response) {
  console.log(response);
});

步骤 2) 通过 [unzip (blob)][3] 解压下载的文件?

步骤 3) 可能提供两种选择:

(a) 指示 Google 表格通过 =importData("URL") 将数据下载到自身中,这需要将 CSV 保存在我的 Google Drive 之类的地方

(b) 通过其 [Google Sheet API][4] 将其推送到 Google Sheet 中

【问题讨论】:

    标签: api csv google-apps-script qualtrics


    【解决方案1】:
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-11-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多