我是新的bigquery,在这里,我试图加载数据在GCP BigQuery表,我已经手动创建,我有一个bash文件,其中包含bq加载命令-
bq load --source_format=CSV --field_delimiter=$(printf '\u0001') dataset_name.table_name gs://bucket-name/sample_file.csv
我的CSV文件包含多个16列的行-示例行为
100563^3b9888^Buckname^https://www.settttt.ff/setlllll/buckkkkk-73d58581.html^Buckcherry^null^null^2019-12-14^23d74444^Reverb^Reading^Pennsylvania^United States^US^40.3356483^-75.9268747
表模式-
当我从cloud shell执行bash脚本文件时,我得到以下错误-
Waiting on bqjob_r10e3855fc60c6e88_0000016f42380943_1 ... (0s) Current status: DONE
BigQuery error in load operation: Error processing job 'project-name-
staging:bqjob_r10e3855fc60c6e88_0000ug00004521': 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:
- gs://bucket-name/sample_file.csv: Error while
reading data, error message: CSV table references column position
15, but line starting at position:0 contains only 1 columns.
解决方案是什么,提前感谢
3条答案
按热度按时间doinxwow1#
您试图按照所提供的模式向表中插入错误的值
基于表模式和数据示例,我运行以下命令:
第1个错误
故障详情:- 阅读数据时出错,错误信息:无法将“39 b888”分析为从位置0开始的字段Field 2(位置1)的int
在这一点上,我手动删除了39 b888中的B,现在我得到了这个
第二个错误
故障详情:- 阅读数据时出错,错误信息:无法将“14/12/2019”分析为从位置0开始的字段Field 8(位置7)的日期
在这一点上,我将14/12/2019更改为2019-12-14,这是BQ日期格式,现在一切正常
上传完成。正在等待bqjob_r9cb3e4ef5ad596e_0000016f42abd4f6_1...(0 s)当前状态:完成
您需要在上传之前清理数据,或者使用带有
--max_bad_records
标志的更多行的数据样本(有些行可以,有些行不基于您的数据质量)注意:不幸的是,在上传过程中无法控制日期格式,请参阅此answer作为参考。
jfgube3f2#
我们在将数据从本地导入到BigQuery时遇到了同样的问题。在研究数据后,我们看到有以\r或\s enter image description here开头的数据
在实现
ua['ColumnName'].str.strip()
和ua['District'].str.rstrip()
之后,我们可以向Bg添加数据。谢谢
bxgwgixi3#
我们在从本地导入数据到BigQuery时遇到了同样的问题。在测试了这么多选项之后,我们发现错误的原因是数据中的列数与模式中的列数不匹配。希望这对一些人有帮助。🙂