Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/google-sheets/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Google apps script 获取XML文件-在添加新行之前查找重复项_Google Apps Script_Google Sheets - Fatal编程技术网

Google apps script 获取XML文件-在添加新行之前查找重复项

Google apps script 获取XML文件-在添加新行之前查找重复项,google-apps-script,google-sheets,Google Apps Script,Google Sheets,我是法国人,也是应用程序脚本的初学者 我的问题是: 我从一个“var resultat=UrlFetchApp.fetch(url).getContentText();”中获取数据,该文件提供了一个XML文件 我想在我的电子表格中添加结果,但在此之前,我想知道该行是否已经存在于我的电子表格中。 我尝试这样做: function GetMeteo() { url = "http://www.yr.no/place/France/Alsace/Strasbourg/forecast_hour_by_

我是法国人,也是应用程序脚本的初学者

我的问题是: 我从一个“
var resultat=UrlFetchApp.fetch(url).getContentText();
”中获取数据,该文件提供了一个XML文件 我想在我的电子表格中添加结果,但在此之前,我想知道该行是否已经存在于我的电子表格中。 我尝试这样做:

function GetMeteo() {
url = "http://www.yr.no/place/France/Alsace/Strasbourg/forecast_hour_by_hour.xml";
var resultat  = UrlFetchApp.fetch(url).getContentText();

var root  = XmlService.parse(resultat).getRootElement();
var entries = root.getChild('forecast').getChild('tabular').getChildren();

var sheet = SpreadsheetApp.getActiveSheet();
var data = sheet.getDataRange().getValues();
var newData = new Array();

for (var i =0 ; i < entries.length; i++) {
var heure = entries[i].getAttribute('from').getValue();
var precipitation = entries[i].getChild('precipitation').getAttribute('value').getValue();
var windDirection  = entries[i].getChild('windDirection').getAttribute('deg').getValue();
var windSpeed  = entries[i].getChild('windSpeed').getAttribute('mps').getValue();
var temperature = entries[i].getChild('temperature').getAttribute('value').getValue();
var pressure = entries[i].getChild('pressure').getAttribute('value').getValue();



var duplicate = -1;
Données.activate();
var data = Données.getDataRange().getValues();

for (j in data) {
  if (data[j][0] == heure) {
    duplicate = j;
  }
  else {
    duplicate = -1;
  }
}
if (NumLigne == -1) {

   data.push({heure,precipitation,windDirection,windSpeed,temperature,pressure});
}
else {
      data[NumLigne].push({heure,precipitation,windDirection,windSpeed,temperature,pressure});
 }
}
函数GetMeteo(){ url=”http://www.yr.no/place/France/Alsace/Strasbourg/forecast_hour_by_hour.xml"; var resulttat=UrlFetchApp.fetch(url.getContentText(); var root=XmlService.parse(resultat.getRootElement(); var entries=root.getChild('forecast').getChild('tabular').getChildren(); var sheet=SpreadsheetApp.getActiveSheet(); var data=sheet.getDataRange().getValues(); var newData=newarray(); 对于(变量i=0;i 但是数据推送不起作用