Python 3.x bigquery中的InvalidResponse错误从\u文件加载\u表\u
我试图从BytesIO对象将一组csv数据上传到BigQuery中,但不断收到错误Python 3.x bigquery中的InvalidResponse错误从\u文件加载\u表\u,python-3.x,google-bigquery,Python 3.x,Google Bigquery,我试图从BytesIO对象将一组csv数据上传到BigQuery中,但不断收到错误InvalidResponse:Response标头必须包含标头“位置” 这是我的密码 # self.database = authenticated bigquery.Client config = bigquery.LoadJobConfig() config.skip_leading_rows = 1 config.source_format = bigquery.SourceFormat.CSV conf
InvalidResponse:Response标头必须包含标头“位置”
这是我的密码
# self.database = authenticated bigquery.Client
config = bigquery.LoadJobConfig()
config.skip_leading_rows = 1
config.source_format = bigquery.SourceFormat.CSV
config.allow_jagged_rows = True
schema = [
bigquery.SchemaField("date", "DATE", mode="REQUIRED"),
bigquery.SchemaField("page_id", "STRING", mode="REQUIRED")
]
# ... Appending a list of bigquery.SchemaField("name", "INTEGER")
config.schema = schema
table = self.get_or_create_table(name, config.schema) # returns TableReference
file = self.clip_data(local_fp, cutoff_date) # returns BytesIO
job = self.database.load_table_from_file(
file, table,
num_retries=self.options.num_retries,
job_id=uuid.uuid4().int,
job_config=config
) # Error is here.
我已尝试四处搜索,但找不到任何原因或修复此异常
InvalidResponse: ('Response headers must contain header', 'location')
该问题是由于在
load\u table\u from\u file
方法中未提供位置而导致的
location="US"
已经足够解决问题。阅读更多文档,我发现load\u table\u from\u file
接受location
参数,但不幸的是,设置此参数并没有以任何方式减轻错误。撤回上一条注释后,我的Spyder控制台没有正确刷新文件,location
正是我需要使用的。我确实设置了location
,但仍然得到相同的错误。有什么想法吗?