【问题标题】:RESOURCE_EXHAUSTED when extracting from Google Form to Google Sheet从 Google 表单提取到 Google 表格时的 RESOURCE_EXHAUSTED
【发布时间】:2021-10-03 22:24:15
【问题描述】:

我正在尝试将 Google 表单的问题和多项选择选项提取到 Google 表格中。我在这里找到了一个解决方案 (Is it possible to export questions and multiple choice options from a Google Form to a Google Sheet?),在 alberto vielma 的回答中(2019 年 10 月 28 日 12:06 的回答)。

但是,我在尝试 Alberto 的脚本时遇到了错误(“我们很抱歉,创建 Cloud Platform 项目时出现意外错误。错误代码 RESOURCE_EXHAUSTED。”)。

这让我很吃惊,因为几个月前我已经成功使用了这个脚本……有谁知道到底出了什么问题?

(我创建了一个新主题,因为关于回答的“提示”表明,如果我只有额外的问题,我不应该“参与”上述主题。)

为方便起见,我将在此处复制 Alberto 的脚本:

var form = FormApp.openById('YOUR-FORM-ID');
// Open a sheet by ID.
var sheet = SpreadsheetApp.openById('YOUR-SHEET-ID').getSheets()[0];

// variables for putting the questions and answers in the right position
var question_position = 0;
var answers_position = 0;

// main function to run
function getFormValues() {
  form.getItems().forEach(callback);
}

// Iterate over all questions 
function callback(el){
  
  // check if the question is multiple choice
  if (el.getType() == FormApp.ItemType.MULTIPLE_CHOICE) {
    // change the type from Item to MultipleChoiceItem
    var question = el.asMultipleChoiceItem();
    var choices = question.getChoices();
    // set the title of the question in the cell
    sheet.getRange(question_position +1, 1).setValue(question.getTitle());
    
    var i = 0;
    // set the answers in the right cells
    for (i; i < choices.length; i++){
      sheet.getRange(answers_position + 1, 2).setValue(choices[i].getValue());
      answers_position++;
    }
    question_position += i;
    answers_position++;
  }
  question_position++;
  
}

【问题讨论】:

  • 我从电子表格创建表单。我允许用户在同一个电子表格中选择或不选择响应,并用答案填充 ss。我无法在表格中填写“简短答案”,但几乎所有其他内容都有效。 docs.google.com/spreadsheets/d/…

标签: google-apps-script google-sheets google-forms


【解决方案1】:

当您遇到错误时,是否有任何值写入您的电子表格?

我想知道它处理使用限制,因为电子表格中有很多 setValue

也许您可以尝试首先将所有单个值(问题和选择)推送到数组values。最后使用setValues(values)减少setValue的调用次数。

或者您可以尝试在每个循环中添加一些Utilies.sleep(milliseconds)

【讨论】:

    【解决方案2】:

    这是一个影响今天早些时候一些用户的已知问题(似乎不再持续存在。)参考https://issuetracker.google.com/issues/194826559?pli=1

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2023-01-04
      • 2020-01-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多