Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/python-3.x/18.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 3.x bigquery中的InvalidResponse错误从\u文件加载\u表\u_Python 3.x_Google Bigquery - Fatal编程技术网

Python 3.x bigquery中的InvalidResponse错误从\u文件加载\u表\u

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

我试图从BytesIO对象将一组csv数据上传到BigQuery中,但不断收到错误
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
,但仍然得到相同的错误。有什么想法吗?