1 python google-analytics google-analytics-api google-bigquery
这是从 Biq Query 导出到 Google 存储的简单代码(以 CSV 格式)
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))
Run Code Online (Sandbox Code Playgroud)
它非常适合通用表,但是当我尝试从保存的表 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.
Run Code Online (Sandbox Code Playgroud)
有没有办法从表视图导出数据?
我想要实现的是,从 BigQuery 获取 CSV 格式的数据,然后上传到 Google Analytics 产品数据
| 归档时间: |
|
| 查看次数: |
4787 次 |
| 最近记录: |