csv - 通过命令行在 BQ 中加载 CSV
问题描述
我一直在尝试使用此命令在 bigquery 中加载 csv 文件,但一直出错。我的 csv 文件看起来像这样,我的文件总共有 40 行,仅包括标题。当我尝试使用控制台 gui 加载 csv 文件时出现同样的错误
header 1,header 2,Header 3,Header 4,Header 5,Header 6,header 7,Header 8,header 9,Header 10
Justine,Mobile,Address,Location,2020-01-26,1,0,11,3,1
使用此命令行:
bq load --allow_jagged_rows=1 --skip_leading_rows=1 --source_format=CSV datasetId.mytableid /home/username/file.csv
我得到了这个错误
Upload complete.
Waiting on bqjob_r421ecc680c644b1b_0000016fdb99efe1_1 ... (1s) Current status: DONE
BigQuery error in load operation: Error processing job 'my-project-id:bqjob_r4212fs8997c644b1b_000db99efe1_1': Error while reading data, error message: CSV table encountered too many errors,
giving up. Rows: 1; errors: 1. Please look into the errors[] collection for more details.
Failure details:
- Error while reading data, error message: Error detected while
parsing row starting at position: 309. Error: Bad character (ASCII
0) encountered.
解决方案
bq load --source_format=CSV project_id:dataset.tablename /PATH_TO_FILE/airports.csv IATA:STRING,AIRPORT:STRING,CITY:STRING,STATE:STRING,COUNTRY:STRING,LATITUDE:FLOAT64,LONGITUDE:FLOAT64
我只是从 CVS 中删除了第一行(标题),因为我已经在命令中提到了模式和数据类型。然后我运行上面的命令,它为我创建了表
推荐阅读
- r - as.Date 函数不起作用 n 数据表
- google-cloud-platform - 在删除之前检查计算引擎实例是否存在
- sql - 我如何格式化列
- c# - 如何在c#中为excel单元格设置默认颜色?
- python - 我只想导入 spacy 但我收到 msgpack 错误
- angular - 如何完成对 REST API 的 http 调用?
- java - 数一手花色的数量
- visual-studio - 如何在未安装 VS 的 Windows 中使用“Microsoft tfs Shell Extension”
- java - 为什么spring调度程序加载两次?
- algorithm - 了解动态规划中的基本案例