我正在嘗試使用 Cloud Function 將 CSV 從 Cloud Storage 加載到 Big Query。該檔案的某些字串中有換行符。
當我從 Cloud Shell 加載時,它會完美加載,并且可以在帶有換行符的表中找到字串。
bq --location=EU load \
--replace \
--allow_quoted_newlines \
--skip_leading_rows=1 \
--source_format=CSV \
my_gcp_project:my_dataset.my_table \
gs://9604/data/data.csv \
my_schema.json
在我的云函式中,我得到了錯誤,
讀取資料時出錯,錯誤訊息:決議從位置開始的行時檢測到錯誤:2624400。錯誤:缺少右雙引號 (") 字符。
將 Cloud Function 與 Node.js 10 一起使用,對我來說設定相同;
const datasetId = 'my_dataset';
const tableId = 'my_table';
const metadata = {
sourceFormat: 'CSV',
skipLeadingRows: 1,
allowQuotedNewlines: True,
schema: {
fields: [{"name": "gdb", "type": "STRING"},
{"name": "venueid", "type": "STRING"},
{"mode": "NULLABLE", "name": "buildingid", "type": "STRING"},
{"mode": "NULLABLE", "name": "floorexists", "type": "STRING"},
{"mode": "NULLABLE", "name": "roomid", "type": "STRING"},
{"mode": "NULLABLE", "name": "displayname", "type": "STRING"},
{"mode": "NULLABLE", "name": "zlevel", "type": "INTEGER"},
{"mode": "NULLABLE", "name": "class", "type": "STRING"},
{"mode": "NULLABLE", "name": "accesslevel", "type": "STRING"},
{"mode": "NULLABLE", "name": "created_date", "type": "DATETIME"},
{"mode": "NULLABLE", "name": "year", "type": "STRING"},
{"mode": "NULLABLE", "name": "quarter", "type": "STRING"},
{"mode": "NULLABLE", "name": "yearquarter", "type": "STRING"},
{"mode": "NULLABLE", "name": "month", "type": "STRING"},
{"mode": "NULLABLE", "name": "area_sqm", "type": "FLOAT"},
{"mode": "NULLABLE", "name": "area_sqft", "type": "FLOAT"}],
},
// Set the write disposition to overwrite existing table data.
writeDisposition: 'WRITE_TRUNCATE',
location: 'EU',
};
我錯過了什么?感謝您的輸入!
uj5u.com熱心網友回復:
發現問題。對于架構,我有:
{'name': 'gdb', 'type' : 'STRING'},
{'name': 'venueid', 'type' : 'STRING'},
洗掉“”解決了這個問題。所以,使用 GSUTIL 就很好,在 JS 中就沒有那么多了。作業模式:
{name: 'gdb', type: 'STRING'},
{name: 'venueid', type: 'STRING'}
轉載請註明出處,本文鏈接:https://www.uj5u.com/qiye/475891.html
