Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/google-apps-script/6.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
Javascript 应用程序脚本写入大查询未知错误_Javascript_Google Apps Script_Google Bigquery - Fatal编程技术网

Javascript 应用程序脚本写入大查询未知错误

Javascript 应用程序脚本写入大查询未知错误,javascript,google-apps-script,google-bigquery,Javascript,Google Apps Script,Google Bigquery,这应该在CSV中读取,然后将其写入bigquery。但是,当它运行时,不会写入任何内容,也不会记录任何错误。我读到我需要写一个csv,然后把它转换成八位字节流。我不确定这是否与google bigquery兼容 function test(){ try{ var tableReference = BigQuery.newTableReference(); tableReference.setProjectId(PROJECT_ID); tableReference.setDatase

这应该在CSV中读取,然后将其写入bigquery。但是,当它运行时,不会写入任何内容,也不会记录任何错误。我读到我需要写一个csv,然后把它转换成八位字节流。我不确定这是否与google bigquery兼容

function test(){
try{
  var tableReference = BigQuery.newTableReference();
  tableReference.setProjectId(PROJECT_ID);
  tableReference.setDatasetId(datasetId);
  tableReference.setTableId(tableId);
  var schema = "CUSTOMER:string, CLASSNUM:integer, CLASSDESC:string, CSR:string, CSR2:string, INSURANCE:string, REFERRALGENERAL:string, REFERRALSPECIFIC:string, NOTES:string, INMIN:integer, INHR:integer, OUTMIN:integer, OUTHR:integer, WAITMIN:integer, WAITHR:integer, DATETIMESTAMP:float, DATEYR:integer,DATEMONTH:integer, DATEDAY:integer";
  var load = BigQuery.newJobConfigurationLoad();
  load.setDestinationTable(tableReference);
  load.setSourceUris(URIs);
  load.setSourceFormat('NEWLINE_DELIMITED_JSON');
  load.setSchema(schema);
  load.setMaxBadRecords(0);
  load.setWriteDisposition('WRITE_TRUNCATE');

  var configuration = BigQuery.newJobConfiguration();
  configuration.setLoad(load);

  var newJob = BigQuery.newJob();
  newJob.setConfiguration(configuration);


  var loadr = DriveApp.getFilesByName("test.csv");
  var x = loadr.next().getBlob();
  Logger.log(x.getDataAsString());

  var d = DriveApp.getFilesByName("test.csv");
  var id = d.next().getId();
  Logger.log(id);
  var data = DocsList.getFileById(id).getBlob().getDataAsString();
  var mediaData = Utilities.newBlob(data, 'application/octet-stream');

  BigQuery.Jobs.insert(newJob, PROJECT_ID, mediaData) 
 }
 catch(error){Logger.log("A" + error.message);}
}

CSV文件的sourceFormat错误:

数据文件的格式。对于CSV文件,请指定“CSV”。对于 数据存储备份,指定“数据存储\u备份”。对于换行符分隔的 JSON,指定“换行符分隔的JSON”。默认值为CSV


另一方面,我认为您根本不需要加载.setSourceURI(URI)因为您尝试从本地文件加载,而不是从Google云存储加载。检查这个python示例

我将sourceFormat更改为CSV并删除了setSourceURI,但它仍然没有写入,也没有显示错误。我再次输入了setSourceUris,没有错误。我真的不知道该怎么办。我所需要做的就是让这部分工作,我完成了这个项目的Bigquery方面。你有你的问题的答案吗?谢谢