Upload de folhas do Google para bigquery: Caractere incorreto
O script dos meus aplicativos foi modificado dehttps://developers.google.com/apps-script/advanced/bigquery.
Eu continuo recebendo erros assim:
File: 0 / Line:6 / Field:1, Bad character (ASCII 0) encountered: field starts with: < c7d��{>
File: 0 / Line:7 / Field:1, Bad character (ASCII 0) encountered: field starts with: < #7��v#>
File: 0 / Line:13 / Field:1, Bad character (ASCII 0) encountered: field starts with: < c7d�1>
File: 0 / Line:17 / Field:1, Bad character (ASCII 0) encountered: field starts with: <�+�d��>
File: 0 / Line:20 / Field:1, Bad character (ASCII 0) encountered: field starts with: <7�J�F�)�>
Aqui está o meu código:
function loadCsv() {
// Replace this value with the project ID listed in the Google
// Developers Console project.
var projectId = 'summer-rope-861';
// Create a dataset in the BigQuery UI (https://bigquery.cloud.google.com)
// and enter its ID below.
var datasetId = 'expedia_sem';
// Sample CSV file of Google Trends data conforming to the schema below.
// https://docs.google.com/file/d/0BwzA1Orbvy5WMXFLaTR1Z1p2UDg/edit
var csvFileId = '1JjShLEoLmPME6vdYbIAQy7iF5EgpHLArcJ9jxwkH-sY';
// Delete and reCreate the table.
var tableId = 'aud_info';
BigQuery.Tables.remove(projectId, datasetId, tableId);
var table = {
tableReference: {
projectId: projectId,
datasetId: datasetId,
tableId: tableId
},
schema: {
fields: [
{name: 'ListID', type: 'STRING'},
{name: 'ListName', type: 'STRING'},
{name: 'ListDescription', type: 'STRING'},
{name: 'AudienceCategory', type: 'STRING'}
]
}
};
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,
allowJaggedRows: true
}
}
};
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);
}
O que estou fazendo errado? Parece um problema de codificação, mas o Planilhas não está no formato UTF-8?
Meus dados são assim:
Quando executo data.getDataAsString () no Logger, recebo
% PDF-1.4% 2 0 obj <> stream x MO @ F bF $ a ? FiC8X (b " w $ PZ if6 gf 0 Xo I ? ע P aTYCѠs $ - O $ O d & S B - Q2 ? vZR `nD + $ u Y (.7 6 = Ā w8 ށ K dk- JFJ x J -) N% L - [L Nȣ w0 9 a4 d ] 4Eu = G @ V w FPr K aU ݴ GR R A * F p 9 / end end endjj 4 0 obj <>>> / Pai 3 0 R / MediaBox [0 0 612 792] >> endobj 5 0 obj <> fluxo x xE ? VwO = 3 ̑L2 L.2 J d $ } "A @ 9D TT 1 U ]] V ^ u U1 Vw v {~ O> U] U [o oUG Ae o} 9 / {ɜW ] q e ...