-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgenerate_mock_data.py
More file actions
44 lines (36 loc) · 1.7 KB
/
generate_mock_data.py
File metadata and controls
44 lines (36 loc) · 1.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import json
import random
donors = ["United States", "Germany", "United Kingdom", "Japan", "France", "Canada", "Sweden", "Norway", "Australia", "Netherlands"]
recipients = ["India", "Afghanistan", "Ukraine", "Kenya", "Nigeria", "Ethiopia", "Bangladesh", "Vietnam", "Pakistan", "Tanzania", "DR Congo", "Syria"]
sectors = ["Health", "Education", "Infrastructure", "Humanitarian Aid", "Agriculture", "Governance"]
data = []
# Generate consistent flows
for donor in donors:
# Each donor gives to 3-8 recipients
my_recipients = random.sample(recipients, k=random.randint(3, 8))
for recipient in my_recipients:
# Generate yearly data
for year in range(2018, 2024):
# Base amount with some variance
base_amount = random.randint(10, 500) * 1000000 # 10M to 500M
# Split into sectors
amount_remaining = base_amount
for i, sector in enumerate(sectors):
if amount_remaining <= 0: break
if i == len(sectors) - 1:
amount = amount_remaining
else:
amount = random.randint(0, amount_remaining)
if amount > 0:
data.append({
"id": f"{donor}-{recipient}-{year}-{sector}",
"donor": donor,
"recipient": recipient,
"year": year,
"amount": amount,
"sector": sector
})
amount_remaining -= amount
with open("aid_data.json", "w") as f:
json.dump(data, f, indent=2)
print(f"Generated {len(data)} records in aid_data.json")