csv 파일에서 bigquery로 데이터를로드하기위한 독립 실행 형 스크립트를 작성했지만 스프레드 시트를 bigquery로로드하는 방법을 알고 싶습니다. 다음은 csv에서 bigquery.i 데이터를로드하는 코드입니다. csv 파일 대신 Google 스프레드 시트를 변경할 위치를 알고 싶습니다.google 스프레드 시트에서 bigquery로 데이터를로드하는 독립 실행 형 스크립트
function loadCsv() {
// Replace this value with the project ID listed in the Google
// Developers Console project.
var projectId = '775034665452';
var datasetId = 'DEV';
// Sample CSV file of Google Trends data conforming to the schema below.
// https://docs.google.com/file/d/0BwzA1Orbvy5WMXFLaTR1Z1p2UDg/edit
var csvFileId = '0BwzA1Orbvy5WMXFLaTR1Z1p2UDg';
// Create the table.
var tableId = 'pets_' + new Date().getTime();
var table = {
tableReference: {
projectId: projectId,
datasetId: datasetId,
tableId: tableId
},
schema: {
fields: [
{name: 'week', type: 'STRING'},
{name: 'cat', type: 'INTEGER'},
{name: 'dog', type: 'INTEGER'},
{name: 'bird', type: 'INTEGER'}
]
}
};
table = BigQuery.Tables.insert(table, projectId, datasetId);
Logger.log('Table created: %s', table.id);
// Load CSV data from Drive and convert to the correct format for upload.
var file = DriveApp.getFileById(csvFileId);
var data = file.getBlob().setContentType('application/octet-stream');
// Create the data upload job.
var job = {
configuration: {
load: {
destinationTable: {
projectId: projectId,
datasetId: datasetId,
tableId: tableId
},
skipLeadingRows: 1
}
}
};
job = BigQuery.Jobs.insert(job, projectId, data);
Logger.log('Load job started. Check on the status of it here: ' +
'https://bigquery.cloud.google.com/jobs/%s', projectId);
}
감사합니다! 그러나 나는 우리가 GCS 또는 수동에서로드 대신 BigQuery를 위해 스프레드 시트에서 데이터를로드하기위한 스크립트를 작성할 수 있는지 알고 싶습니다
로드 CSV에게 파일을,이를 확인 . – nikhil
예,이 문서를 확인하십시오. https://cloud.google.com/blog/big-data/2016/05/bigquery-integrates-with-google-drive –