-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path04_split_users.py
More file actions
55 lines (44 loc) · 1.76 KB
/
04_split_users.py
File metadata and controls
55 lines (44 loc) · 1.76 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
45
46
47
48
49
50
51
52
53
54
55
import json
import random
# Load the characters_fixed.json file
with open('characters_fixed_ids.json', 'r') as f:
users_data = json.load(f)
with open('Characters_core.json', 'r') as f:
core_users = json.load(f)
with open('Characters_basic.json', 'r') as f:
basic_users = json.load(f)
with open('bad_org.json', 'r') as f:
organization_users = json.load(f)
# mix users_data and users_data_2
users_data += users_data_2
# Initialize lists for core, basic, and organization users
core_users = []
basic_users = []
organization_users = []
# Classify users into core, basic, and organization categories #TODO: fix this later.
# for user in users_data:
# if user['type'] == "Organization":
# organization_users.append(user)
# elif user['type'] == "Influential Person":
# core_users.append(user)
# else:
# basic_users.append(user)
# Classify users into core, basic, and organization categories randomly since we don't have a user type yet
for user in users_data:
user_type = random.choices(["Basic", "Core", "Organization"], weights=[25, 5, 5], k=1)[0]
if user_type == "Organization":
organization_users.append(user)
elif user_type == "Core":
core_users.append(user)
else:
basic_users.append(user)
# Save the split data into three separate JSON files
with open('core_users.json', 'w') as f:
json.dump(core_users, f, indent=4)
with open('basic_users.json', 'w') as f:
json.dump(basic_users, f, indent=4)
with open('organization_users.json', 'w') as f:
json.dump(organization_users, f, indent=4)
print(f"Users split and saved into core_users.json ({len(core_users)} users), "
f"basic_users.json ({len(basic_users)} users), and "
f"organization_users.json ({len(organization_users)} users).")