24、利用 BigQuery 分析链上数据

BigQuery分析链上数据指南

利用 BigQuery 分析链上数据

1. 将链上数据导入 BigQuery

可以使用以下 Python 脚本将 Google Cloud Storage(GCS)中的 .csv 文件数据加载到 BigQuery 表中:

client = bigquery.Client()
dataset_id = "your_dataset"
table_id = "your_table"
job_config = bigquery.LoadJobConfig(
source_format=bigquery.SourceFormat.CSV, skip_leading_rows=1, 
autodetect=True)
# Get the URI for the blob
uri = f"gs://{bucket_name}/{blob_name}"
load_job = client.load_table_from_uri(
uri, f"{dataset_id}.{table_id}", job_config=job_config
)
# Wait for the load job to complete.
load_job.result()
destination_table = client.get_table(f"{dataset_id}.{table_id}")
print("Loaded {} rows.".format(destination_table.num_rows))

此脚本会自动检测数据类型( autodetect=True ),请将 your-

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值