相关疑难解决方法(0)

将 CSV 导入 BigQuery 中的表时无法添加字段

我有一个 python 脚本,它执行 gbq 作业以将 csv 文件 f 加载到 BigQuery 中的表中。我尝试以 csv 格式上传数据并收到以下错误:

 400 Invalid schema update. Cannot add fields (field: string_field_8)
Run Code Online (Sandbox Code Playgroud)

这是我的 csv:

    id,first_name,username,last_name,chat_username,chat_id,forward_date,message_text
    231125223|Just|koso|swissborg_bounty|-1001368946079|1517903147|tes
  481895079|Emerson|EmersonEmory|swissborg_bounty|-1001368946079|1517904387|pictu
    316560356|Ken Sam|ICOnomix|swissborg_bounty|-1001368946079|1517904515|Today 
Run Code Online (Sandbox Code Playgroud)

这是我的代码:

from google.cloud.bigquery import Client
import os
os.environ['GOOGLE_APPLICATION_CREDENTIALS'] = '***.json'
os.environ['GOOGLE_CLOUD_DISABLE_GRPC'] = 'True'

from google.cloud import bigquery
dataset_name = 'test_temporary_dataset'
table_name='table_telega'
bigquery_client = bigquery.Client()
dataset = bigquery_client.dataset(dataset_name)
table = dataset.table(table_name)
job_config = bigquery.LoadJobConfig()
job_config.source_format = 'text/csv'
job_config.skip_leading_rows = 1
job_config.autodetect = True
job_config.fieldDelimiter='|'
job_config.allow_jagged_rows=True
job_config.ignoreUnknownValues=True
job_config.allow_quoted_newlines=True
with open('**.csv', 'rb') as source_file: …
Run Code Online (Sandbox Code Playgroud)

python csv python-3.x google-bigquery

1
推荐指数
1
解决办法
2356
查看次数

标签 统计

csv ×1

google-bigquery ×1

python ×1

python-3.x ×1