【发布时间】:2020-05-17 06:41:55
【问题描述】:
我正在尝试从大型查询公共数据集中下载数据并将其存储在本地 CSV 文件中。当我在查询末尾添加 LIMIT 10 时,我的代码可以工作,但如果没有,我会收到一条错误消息:
Response too large to return. Consider setting allowLargeResults to true in your job configuration.
提前感谢您!
这是我的代码:
import pandas as pd
import pandas_gbq as gbq
import tqdm
def get_data(query,project_id):
data = gbq.read_gbq(query, project_id=project_id,configuration={"allow_large_results":True})
data.to_csv('blockchain.csv',header=True,index=False)
if __name__ == "__main__":
query = """SELECT * FROM `bigquery-public-data.crypto_bitcoin.transactions` WHERE block_timestamp>='2017-09-1' and block_timestamp<'2017-10-1';"""
project_id = "bitcoin-274091"
get_data(query,project_id)
【问题讨论】:
-
嗨!你有什么问题?它不工作吗?
-
您需要将查询结果保存到表中,然后将该表导出到 GCS 并下载。或者使用存储 API 将其有效地拉过网络。
标签: python pandas google-bigquery