【发布时间】:2018-07-20 14:15:43
【问题描述】:
我创建了一个 python 脚本,用于从 Google Cloud Storage 存储桶中获取 JSON 文件并将其加载到数据集中。 我在尝试指定与文本文件位于同一存储桶中的架构时遇到问题
我的架构文件是一个 txt 文件,格式为 Attribute:DataType,Attribute:DataType
这就是我所拥有的
job_config = bigquery.LoadJobConfig()
schema_uri = 'gs://<bucket-name>/FlattenedProduct_schema.txt'
schema = schema_uri
job_config.schema = schema
job_config.source_format = bigquery.SourceFormat.NEWLINE_DELIMITED_JSON
uri = 'gs://<bucket-name>/FlattenedProduct_JSON.txt'
load_job = client.load_table_from_uri(
uri,
dataset_ref.table('us_states'),
location='US', # Location must match that of the destination dataset.
job_config=job_config) # API request
【问题讨论】:
标签: google-cloud-platform google-bigquery google-cloud-storage