Reputation: 1053
I need to upload data to BigQuery from Drive. I found these two explanations (Upload CSV, BQ Jobs),
However, I don't want to define the schema everytime anew. In manual upload you can check the 'autodetect' but in the script I can't find how to do it.
Thanks
Upvotes: 0
Views: 749
Reputation: 1053
Thanks Elliot.
Here is the updated request:
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,
autodetect: true
}
}
};
job = BigQuery.Jobs.insert(job, projectId, data);
Upvotes: 3
Reputation: 33765
With the jobs.load
API, you are looking for the configuration.load.autodetect
option. There should be a similarly named setting for Apps Script.
Upvotes: 5