RESOURCE_EXHAUSTED 当从 Google 表格提取到 Google Sheet
RESOURCE_EXHAUSTED when extracting from Google Form to Google Sheet
我正在尝试将 Google 表单的问题和多选选项提取到 Google Sheet。我在这里 (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 时遇到错误(“很抱歉,创建云平台项目时出现意外错误。错误代码 RESOURCE_EXHAUSTED”。)脚本。
这让我很吃惊,因为几个月前我已经成功地使用了这个脚本...有谁知道到底出了什么问题?
(我创建了一个新主题,因为关于回答的 'tips' 建议如果我只有额外的问题,我不应该“贡献”上述主题。)
为方便起见,我将阿尔贝托的脚本复制到这里:
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++;
}
出现错误时,您的电子表格中是否写入了任何值?
我想知道它是否处理使用限制,因为您有很多 setValue
电子表格。
也许您可以尝试先将所有单个值(问题和选择)推送到一个数组values
。最后使用 setValues(values) 来减少 setValue
.
的调用次数
或者您可以尝试在每个循环中添加一些 Utilies.sleep(milliseconds)。
这是一个已知问题,今天早些时候影响了一些用户(似乎不再持续存在。)参考 https://issuetracker.google.com/issues/194826559?pli=1
我正在尝试将 Google 表单的问题和多选选项提取到 Google Sheet。我在这里 (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 时遇到错误(“很抱歉,创建云平台项目时出现意外错误。错误代码 RESOURCE_EXHAUSTED”。)脚本。
这让我很吃惊,因为几个月前我已经成功地使用了这个脚本...有谁知道到底出了什么问题?
(我创建了一个新主题,因为关于回答的 'tips' 建议如果我只有额外的问题,我不应该“贡献”上述主题。)
为方便起见,我将阿尔贝托的脚本复制到这里:
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++;
}
出现错误时,您的电子表格中是否写入了任何值?
我想知道它是否处理使用限制,因为您有很多 setValue
电子表格。
也许您可以尝试先将所有单个值(问题和选择)推送到一个数组values
。最后使用 setValues(values) 来减少 setValue
.
或者您可以尝试在每个循环中添加一些 Utilies.sleep(milliseconds)。
这是一个已知问题,今天早些时候影响了一些用户(似乎不再持续存在。)参考 https://issuetracker.google.com/issues/194826559?pli=1