[英]Export Google BigQuery data to Python Pandas dataframe
[英]BigQuery | Python | Export data from BigQuery table VIEW
這是一個簡單的代碼,可以CSV格式從Biq查詢導出到Google存儲空間
def export_data():
client = bigquery.Client()
project = 'xxxxx'
dataset_id = 'xxx'
table_id = 'xxx'
bucket_name = 'xxx'
destination_uri = 'gs://{}/{}'.format(bucket_name, 'EXPORT_FILE.csv')
dataset_ref = client.dataset(dataset_id, project=project)
table_ref = dataset_ref.table(table_id)
extract_job = client.extract_table(
table_ref,
destination_uri,
# Location must match that of the source table.
location='EU') # API request
extract_job.result() # Waits for job to complete.
print('Exported {}:{}.{} to {}'.format(
project, dataset_id, table_id, destination_uri))
它非常適合常規表,但是當我嘗試從已保存的表VIEW中導出數據時,由於以下錯誤而失敗:
BadRequest: 400 Using table xxx:xxx.xxx@123456 is not allowed for this operation because of its type. Try using a different table that is of type TABLE.
是否存在從表視圖導出數據的任何方法?
我想要實現的是從BigQuery以CSV格式獲取數據,並將其上傳到Google Analytics(分析)產品數據
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.