Created
May 7, 2023 12:23
-
-
Save auxten/1d691e5ac383dcf4e6387d2380ea0670 to your computer and use it in GitHub Desktop.
chdb on uniswap_v2_trading_data
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import chdb | |
data_path = "/home/Clickhouse/bench/uniswap_v2_trading_data/*.csv" | |
small_data_path = "/home/Clickhouse/bench/uniswap_v2_trading_data/v2_trading_history_14025747.csv" | |
print("Sample: ", | |
chdb.query(f"select * from file('{data_path}', 'CSVWithNames') limit 10", "PrettyCompact").data()) | |
print("Count: ", chdb.query(f"select count(*) from file('{data_path}', 'CSVWithNames')").data()) | |
# ret = chdb.query( | |
# f"select timestamp, tx, amount1_in, amount1_out from file('{data_path}', 'CSVWithNames') limit 10", "Pretty") | |
# print(ret.data()) | |
# avg of position_in_block group by gecko_id0 | |
ret = chdb.query(f"select gecko_id0, count(*) cnt, avg(position_in_block) pos \ | |
from file('{data_path}', 'CSVWithNames') group by gecko_id0 order by cnt desc limit 10", | |
"Pretty") | |
print("Avg of position_in_block group by gecko_id0: ", ret.data()) | |
ret = chdb.query(f"select gecko_id0, avg(position_in_block) pos \ | |
from file('{data_path}', 'CSVWithNames') group by gecko_id0 limit 10", "DataFrame") | |
print(ret, type(ret)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment