nice-bill commited on
Commit
88be3ab
·
1 Parent(s): 057d322

wallet and request script added

Browse files
Files changed (6) hide show
  1. .gitignore +12 -0
  2. .python-version +1 -0
  3. pyproject.toml +9 -0
  4. request.py +59 -0
  5. uv.lock +23 -0
  6. wallet_dataset.csv +0 -0
.gitignore ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Python-generated files
2
+ __pycache__/
3
+ *.py[oc]
4
+ build/
5
+ dist/
6
+ wheels/
7
+ *.egg-info
8
+
9
+ # Virtual environments
10
+ .venv
11
+
12
+ .env
.python-version ADDED
@@ -0,0 +1 @@
 
 
1
+ 3.12
pyproject.toml ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ [project]
2
+ name = "cluster"
3
+ version = "0.1.0"
4
+ description = "Add your description here"
5
+ readme = "README.md"
6
+ requires-python = ">=3.12"
7
+ dependencies = [
8
+ "python-dotenv>=1.2.1",
9
+ ]
request.py ADDED
@@ -0,0 +1,59 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import requests
2
+ import csv
3
+ import time
4
+ from dotenv import load_dotenv
5
+ import os
6
+ load_dotenv()
7
+
8
+ API_KEY = os.getenv("DUNE_API_KEY")
9
+
10
+ QUERY_ID = "6246979"
11
+ LIMIT = 1000
12
+ offset = 0
13
+
14
+ output_file = "wallet_dataset.csv"
15
+ first_page = True
16
+
17
+ print("Downloading full dataset from Dune…")
18
+
19
+ while True:
20
+ url = f"https://api.dune.com/api/v1/query/{QUERY_ID}/results/csv?limit={LIMIT}&offset={offset}"
21
+ headers = {"X-Dune-API-Key": API_KEY}
22
+
23
+ print(f"Fetching offset {offset} ...")
24
+
25
+ try:
26
+ r = requests.get(url, headers=headers, timeout=40)
27
+
28
+ except requests.exceptions.Timeout:
29
+ print("Timeout. Retrying in 5 seconds…")
30
+ time.sleep(5)
31
+ continue
32
+
33
+ except Exception as e:
34
+ print(f"Network error: {e}. Retrying…")
35
+ time.sleep(5)
36
+ continue
37
+
38
+ if len(r.text.strip()) == 0 or r.status_code != 200:
39
+ print("No more rows or bad response. Finished.")
40
+ break
41
+
42
+ lines = r.text.splitlines()
43
+ if len(lines) <= 1:
44
+ print("Reached the last partial page. Stopping.")
45
+ break
46
+
47
+ mode = 'w' if first_page else 'a'
48
+ with open(output_file, mode, newline='') as f:
49
+ writer = csv.writer(f)
50
+ for i, line in enumerate(lines):
51
+ if not first_page and i == 0:
52
+ continue
53
+ writer.writerow(line.split(','))
54
+
55
+ first_page = False
56
+ offset += LIMIT
57
+ time.sleep(0.3)
58
+
59
+ print(f"Saved CSV to: {output_file}")
uv.lock ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ version = 1
2
+ revision = 3
3
+ requires-python = ">=3.12"
4
+
5
+ [[package]]
6
+ name = "cluster"
7
+ version = "0.1.0"
8
+ source = { virtual = "." }
9
+ dependencies = [
10
+ { name = "python-dotenv" },
11
+ ]
12
+
13
+ [package.metadata]
14
+ requires-dist = [{ name = "python-dotenv", specifier = ">=1.2.1" }]
15
+
16
+ [[package]]
17
+ name = "python-dotenv"
18
+ version = "1.2.1"
19
+ source = { registry = "https://pypi.org/simple" }
20
+ sdist = { url = "https://files.pythonhosted.org/packages/f0/26/19cadc79a718c5edbec86fd4919a6b6d3f681039a2f6d66d14be94e75fb9/python_dotenv-1.2.1.tar.gz", hash = "sha256:42667e897e16ab0d66954af0e60a9caa94f0fd4ecf3aaf6d2d260eec1aa36ad6", size = 44221, upload-time = "2025-10-26T15:12:10.434Z" }
21
+ wheels = [
22
+ { url = "https://files.pythonhosted.org/packages/14/1b/a298b06749107c305e1fe0f814c6c74aea7b2f1e10989cb30f544a1b3253/python_dotenv-1.2.1-py3-none-any.whl", hash = "sha256:b81ee9561e9ca4004139c6cbba3a238c32b03e4894671e181b671e8cb8425d61", size = 21230, upload-time = "2025-10-26T15:12:09.109Z" },
23
+ ]
wallet_dataset.csv ADDED
The diff for this file is too large to render. See raw diff