Google sheets Google Sheets-拉取数据功能不需要';I don’我不想玩历史存储功能

Google sheets Google Sheets-拉取数据功能不需要';I don’我不想玩历史存储功能,google-sheets,compiler-errors,Google Sheets,Compiler Errors,我发现有几个函数满足了我的需求,但它们不想在一起玩得很好。目标是每天提取一次数据,然后将其添加到新列中。历史记录功能很好,我有一个每天运行一次的触发器设置,但是当尝试自动运行并向我发送一封包含以下内容的电子邮件时,它会出错 6/18/18 5:29 PM loadRegionAggregates TypeError: Cannot find function forEach in object [object Object]. (line 19, file "Code") time-bas

我发现有几个函数满足了我的需求,但它们不想在一起玩得很好。目标是每天提取一次数据,然后将其添加到新列中。历史记录功能很好,我有一个每天运行一次的触发器设置,但是当尝试自动运行并向我发送一封包含以下内容的电子邮件时,它会出错

6/18/18 5:29 PM loadRegionAggregates    TypeError: Cannot find function
forEach in object [object Object]. (line 19, file
"Code") time-based  6/18/18 5:29 PM
下面是完整的code.gs(我用第19行加粗了该部分,函数的第一行)

注意:当我在本地运行脚本时,我的原始代码可以正常工作,只是当每日计时器关闭时就不行了。我假设链接查询中列出的关于嵌套对象上没有forEach类的问题适用于运行trigger.gs的任何对象

编辑:好的,我整天都在做这个。我已经学会了如何设置数组变量(因为我不需要更改数组,静态工作),从那以后我一直在尝试调整其余的代码。到目前为止,我的情况如下:

// Requires a list of typeids, so something like Types!A:A
// https://docs.google.com/spreadsheets/d/1IixV0eNqg19FE6cLzb83G1Ucb0Otl-Jnvm6csAlPKwo/edit?usp=sharing for an example

function loadRegionAggregates(priceIDs,regionID){
  if (typeof regionID == 'undefined'){
    regionID=10000002;
  }
  if (typeof priceIDs == 'undefined'){
    priceIDs = [34,35,36,37,38,39,40,11399];


  }


  var prices = new Array();
  var dirtyTypeIds = new Array();
  var cleanTypeIds = new Array();

  var url="https://market.fuzzwork.co.uk/aggregates/?station=60003760&types=34,35,36,37,38,39,40"


// for (var priceIDs) {
//    if (row.hasOwnProperty(column)) {
//        var cell = row[column];

//        if (typeof cell == "number") {
           priceIDs.push(priceIDs);
//        }
//    }

// }


  cleanTypeIds = dirtyTypeIds.filter(function(v,i,a) {
    return a.indexOf(v)===i;
  });

  prices.push(['TypeID','Buy volume','Buy Weighted Average','Max Buy','Min Buy','Buy Std Dev','Median Buy','Percentile Buy Price','Sell volume','Sell Weighted Average','Max sell','Min Sell','Sell Std Dev','Median Sell','Percentile Sell Price'])
  var parameters = {method : "get", payload : ""};

  var o,j,temparray,chunk = 100;
  for (o=0,j=cleanTypeIds.length; o < j; o+=chunk) {
    temparray = cleanTypeIds.slice(o,o+chunk);
    Utilities.sleep(100);
    var types=temparray.join(",").replace(/,$/,'')
    var jsonFeed = UrlFetchApp.fetch(url+types, parameters).getContentText();
    var json = JSON.parse(jsonFeed);
    if(json) {
      for(i in json) {
        var price=[parseInt(i),
                   parseInt(json[i].buy.volume),
                   parseInt(json[i].buy.weightedAverage),
                   parseFloat(json[i].buy.max),
                   parseFloat(json[i].buy.min),
                   parseFloat(json[i].buy.stddev),
                   parseFloat(json[i].buy.median),
                   parseFloat(json[i].buy.percentile),
                   parseInt(json[i].sell.volume),
                   parseFloat(json[i].sell.weightedAverage),
                   parseFloat(json[i].sell.max),
                   parseFloat(json[i].sell.min),
                   parseFloat(json[i].sell.stddev),
                   parseFloat(json[i].sell.median),
                   parseFloat(json[i].sell.percentile)];
        prices.push(price);
      }
    }
  }
  return prices;
}



function storeData() {
 var sheet = SpreadsheetApp.getActiveSheet();
 var datarange = sheet.getDataRange();
 var numRows = datarange.getNumRows();
 var numColumns = datarange.getNumColumns();

 sheet.getRange(1,numColumns + 1).setValue(new Date());

  for (var i=2; i <= numRows; i++) {

    var prices = sheet.getRange(i, 8).getValue();

    sheet.getRange(i, numColumns + 1).setValue(prices);
  }
}
//需要一个TypeID列表,所以类似于类型!A:A
// https://docs.google.com/spreadsheets/d/1IixV0eNqg19FE6cLzb83G1Ucb0Otl-Jnvm6csAlPKwo/edit?usp=sharing 例如
函数loadRegionAggregates(priceID、regionID){
如果(区域ID的类型=='undefined'){
regionID=10000002;
}
if(typeof priceId==“未定义”){
价格指数=[34,35,36,37,38,39,4011399];
}
var价格=新数组();
var dirtyTypeIds=新数组();
var cleanTypeIds=新数组();
变量url=”https://market.fuzzwork.co.uk/aggregates/?station=60003760&types=34,35,36,37,38,39,40"
//用于(var priceIDs){
//if(行hasOwnProperty(列)){
//变量单元格=行[列];
//如果(单元格类型=“编号”){
priceIDs.push(priceIDs);
//        }
//    }
// }
cleanTypeIds=dirtypeids.filter(函数(v,i,a){
返回a.indexOf(v)==i;
});
价格。推送(['TypeID'、'Buy volume'、'Buy Weighted Average'、'Max Buy'、'Min Buy'、'Buy Std Dev'、'Median Buy'、'Percentile Buy Price'、'Sell volume'、'Sell Weighted Average'、'Max Sell'、'Min Sell Sell Sell Std Dev'、'Medium Sell Sell'、'Percentile Sell Sell Price')
var参数={method:“get”,有效负载:};
var o,j,temparray,chunk=100;
对于(o=0,j=cleanTypeIds.length;o对于(var i=2;我可以记录
priceid
?可能?目前我在单独的选项卡上有它们,并在函数调用中使用它们(a:a)您可以添加函数调用吗?
ReferenceError: "row" is not defined (line 21).
// Requires a list of typeids, so something like Types!A:A
// https://docs.google.com/spreadsheets/d/1IixV0eNqg19FE6cLzb83G1Ucb0Otl-Jnvm6csAlPKwo/edit?usp=sharing for an example

function loadRegionAggregates(priceIDs,regionID){
  if (typeof regionID == 'undefined'){
    regionID=10000002;
  }
  if (typeof priceIDs == 'undefined'){
    priceIDs = [34,35,36,37,38,39,40,11399];


  }


  var prices = new Array();
  var dirtyTypeIds = new Array();
  var cleanTypeIds = new Array();

  var url="https://market.fuzzwork.co.uk/aggregates/?station=60003760&types=34,35,36,37,38,39,40"


// for (var priceIDs) {
//    if (row.hasOwnProperty(column)) {
//        var cell = row[column];

//        if (typeof cell == "number") {
           priceIDs.push(priceIDs);
//        }
//    }

// }


  cleanTypeIds = dirtyTypeIds.filter(function(v,i,a) {
    return a.indexOf(v)===i;
  });

  prices.push(['TypeID','Buy volume','Buy Weighted Average','Max Buy','Min Buy','Buy Std Dev','Median Buy','Percentile Buy Price','Sell volume','Sell Weighted Average','Max sell','Min Sell','Sell Std Dev','Median Sell','Percentile Sell Price'])
  var parameters = {method : "get", payload : ""};

  var o,j,temparray,chunk = 100;
  for (o=0,j=cleanTypeIds.length; o < j; o+=chunk) {
    temparray = cleanTypeIds.slice(o,o+chunk);
    Utilities.sleep(100);
    var types=temparray.join(",").replace(/,$/,'')
    var jsonFeed = UrlFetchApp.fetch(url+types, parameters).getContentText();
    var json = JSON.parse(jsonFeed);
    if(json) {
      for(i in json) {
        var price=[parseInt(i),
                   parseInt(json[i].buy.volume),
                   parseInt(json[i].buy.weightedAverage),
                   parseFloat(json[i].buy.max),
                   parseFloat(json[i].buy.min),
                   parseFloat(json[i].buy.stddev),
                   parseFloat(json[i].buy.median),
                   parseFloat(json[i].buy.percentile),
                   parseInt(json[i].sell.volume),
                   parseFloat(json[i].sell.weightedAverage),
                   parseFloat(json[i].sell.max),
                   parseFloat(json[i].sell.min),
                   parseFloat(json[i].sell.stddev),
                   parseFloat(json[i].sell.median),
                   parseFloat(json[i].sell.percentile)];
        prices.push(price);
      }
    }
  }
  return prices;
}



function storeData() {
 var sheet = SpreadsheetApp.getActiveSheet();
 var datarange = sheet.getDataRange();
 var numRows = datarange.getNumRows();
 var numColumns = datarange.getNumColumns();

 sheet.getRange(1,numColumns + 1).setValue(new Date());

  for (var i=2; i <= numRows; i++) {

    var prices = sheet.getRange(i, 8).getValue();

    sheet.getRange(i, numColumns + 1).setValue(prices);
  }
}