2017-02-22 144 views
3

我试图将GCS中保存的csv文件的数据加载到BigQuery中。 csv文件格式为UTF-8,它包含7列。我已经在数据方案中指定了这些列(所有字符串和可为空),并且检查了csv文件的内容,看起来不错。从Google云端存储加载csv文件时出现BigQuery错误

当我尝试加载我得到以下错误数据:

Too many errors encountered. (error code: invalid) gs://gvk_test_bucket/sku_category.csv: CSV table references column position 1, but line starting at position:1750384 contains only 1 columns. (error code: invalid)

奇怪的是,该文件只包含680228行。

当我检查allow jagged lines选项表正在生成,但只有第一列填充整个逗号分隔的字符串。

有人可以帮助我吗?

例排

119470,Fashion,Fashion Own,Menswear,Menswear Brands Other,Formal Shirts,Long Sleeve Shirts

+0

你检查了文件中的第1750384行吗?如果您将允许的错误数量设置为1,是否加载?你能分享一个样本行吗? –

+0

是的,该行是空的,该文件只包含680228行。没有选项可以说明该文件包含多少行?我将数字设置为1,然后将数字设置为100,但之后它会为另一行返回相同的错误。 – gvkleef

+0

下面是一个样品行: 119470,时尚,时尚自己的,男装,男装品牌其他,正式衬衫,长袖衬衫 – gvkleef

回答

2

你不能在你的文件,而无需分隔符的空行,否则的BigQuery(和几乎所有其他的摄取引擎)会认为这只是一列。

例如,这将在3行失败,您所描述的错误:

119470,Fashion,Fashion Own,Menswear,Menswear Brands Other,Formal Shirts,Long Sleeve Shirts 

119471,Fashion,Fashion Own,Womenswear,Womensswear Brands Other,Formal Shirts,Long Sleeve Shirts 

这会成功:

119470,Fashion,Fashion Own,Menswear,Menswear Brands Other,Formal Shirts,Long Sleeve Shirts 
,,,,,,,  
119471,Fashion,Fashion Own,Womenswear,Womensswear Brands Other,Formal Shirts,Long Sleeve Shirts 
+0

感谢您的评论。有错误的行数大于我excel中的最大行数。所以数据集中没有空行。看来BQ不会停止读取我csv中最后一行之后的数据。 – gvkleef

+0

对不起,我没有关注你。你什么意思? –

+0

例如,我的csv包含80000行,并且在81000,82500等行上发生错误。 – gvkleef

0

要么你有一个空行

119470,Fashion,Fashion Own,Menswear,Menswear Brands Other,Formal Shirts 

119472,Fashion,Fashion Own,Menswear,Menswear Brands Other,Formal Shirts 

或者带引号的行

119470,Fashion,Fashion Own,Menswear,Menswear Brands Other,Formal Shirts 
"119471,Fashion,Fashion Own,Menswear,Menswear Brands Other,Formal Shirts" 
119472,Fashion,Fashion Own,Menswear,Menswear Brands Other,Formal Shirts 

我认为BigQuery响应中存在一个错误。错误中的行号实际上是错误之前的字符数。

+0

这与我的回答有何不同? –

+0

问题还出在这样一个事实,即错误表示行号高于数据集中的行总数。 我试图给予更多的细节更完整的回应。 – Marl

相关问题