Google bigquery 引号和字段分隔符之间的数据
在下面给出的示例中,最后一行未上载。我得到一个错误:Google bigquery 引号和字段分隔符之间的数据,google-bigquery,Google Bigquery,在下面给出的示例中,最后一行未上载。我得到一个错误: Data between close double quote (") and field separator: 这看起来像是一个bug,因为管道符号之间的所有数据都应视为单个字段 模式:一:字符串,二:字符串,三:字符串,四:字符串 上载文件: This | is | test only | to check quotes second | line | "with quotes" | no text third line | with
Data between close double quote (") and field separator:
这看起来像是一个bug,因为管道符号之间的所有数据都应视为单个字段
模式:一:字符串,二:字符串,三:字符串,四:字符串
上载文件:
This | is | test only | to check quotes
second | line | "with quotes" | no text
third line | with | "start quote" and | a word after quotes
处理上面的第一行和第二行。但不是第三个
更新: 有人能解释一下为什么除了第三行之外,下面的内容还能起作用吗
This | is | test only | to check quotes
second | line | "with quotes" | no text
third line | with | "start quote" and | a word after quotes
forth line | enclosed | {"GPRS","MCC_DETECTED":false,"MNC_DETECTED":false} | how does this work?
fifth line | with | {"start quote"} and | a word after quotes
对此可能有一些奇特的解释。从最终用户的角度来看,这是荒谬的。来自:“如果使用双引号括起字段,则必须在字段中出现的双引号前面加上另一个双引号来转义。”
您可能想这样做:
This | is | test only | to check quotes
second | line | "with quotes" | no text
third line | with | " ""start quote"" and " | a word after quotes
有关CSV输入格式的更多信息。上传数据时,您也可以使用其他标志。我使用带有以下标志的bq工具
bq load -F , --source_format CSV --skip_leading_rows 1 --max_bad_records 1 --format csv -E UTF-8 yourdatset gs://datalocation.
- API V2
- bq命令 --quote:用于括起记录的引号字符。默认值为“.”表示完全没有引号字符,请使用空字符串
--quote
非常有效
bq load
--source_format CSV --quote ""
--field_delimiter \t
--max_bad_records 10
-E UTF-8
destination table
Source files
尝试每次使用
bq
shell加载
我不得不加载1100列。当我尝试使用带有所有错误选项的控制台时,它抛出了很多错误。忽略控制台中的错误意味着丢失记录
因此,尝试使用shell并成功加载所有记录
请尝试以下操作:
bq load --source_format CSV --quote "" --field_delimiter \t --allow_jagged_rows --ignore_unknown_values --allow_quoted_newlines --max_bad_records 10 -E UTF-8 {dataset_name}.{table_name} gs://{google_cloud_storage_location}/* {col_1}:{data_type1},{col_2}:{data_type2}, ....
参考资料:
https://cloud.google.com/bigquery/docs/loading-data-cloud-storage-csv#bigquery_load_table_gcs_csv-cli
https://cloud.google.com/bigquery/docs/loading-data-cloud-storage-csv#csv-options
可以尝试以下方法:
- 将MySQL备份文件加载到云SQL实例中
- 直接从MySQL读取BigQuery中的数据