首页 > 解决方案 > 解析从以下位置开始的行时检测到错误:1830577。错误:关闭双引号 (") 和字段分隔符之间的数据

问题描述

我试图将表从 Teradata 加载到 BQ。我的管道首先将表数据导出到 gcs 位置,然后使用 bqload,将数据从 gs:// 加载到 bq 表。

我的 bqload 看起来像这样

bq load --autodetect --source_format=CSV --project_id=xx-xx-xx --field_delimiter='^' \
BQTable \
gs:// \
Name:string,Age:INT64,Place:NUMERIC ...

但是当我尝试使用 bq load 将数据加载到 bq 表中时出现以下错误

Error detected while parsing row starting at position: 1830577. Error: Data between
close double quote (") and field separator.

我尝试在 bqload 命令中使用几个选项,例如 --quote ="" ,当我使用它时,它给了我一个不同的错误,如下所示

Could not parse 'MP' as NUMERIC for field XXXXXX (position 18) starting at
location 1030399 with message 'Invalid NUMERIC value: MP'

也玩了很长时间其他选项,但没有给我任何结果。有人可以发光吗?

标签: bq-load

解决方案


不确定是否仍然活跃的问题,但也许它会在未来帮助某人。

看起来有些数据错误地用双引号括起来(例如123,"some" data,456)。这可能是由转义特殊字符引起的 - 在此处查看有关带双引号的数据的更多信息:Properly escape a double quote in CSV 和此处: https ://gpdb.docs.pivotal.io/43250/admin_guide/load/topics/g-转义-in-csv-formatted-files.html

请注意,默认情况下,NULL 值也会用 " 转义,这可能会导致一些额外的麻烦,例如:例如123,"NULL,"some text value in quotes",456 ,"NULL" 将被解释为字符串值,而 'some text...' 会抛出

Error: Data between close double quote (") and field separator.

您应该从 .csv 文件中删除任何"NULL内容,使其看起来像这样: 123,,"some text value in quotes",456


推荐阅读