blob: 007e36d1f162d2f36d0977b5ad6c8b1322f10da3 [file] [log] [blame]
Eric Park6d1ea8a2019-04-14 00:02:32 +08001import json
2
3# Previous/new JSON file here
4old_file_name = "profile.json"
5new_file_name = "profile_new.json"
6
7# Read previous JSON
8with open(old_file_name, "r") as read_json:
9 old_data = json.load(read_json)
10 print("JSON loaded successfully. Beginning conversion...")
11
12# Initialize new dictionary
13user_list = []
14
15# Conversion
16index = 0
17for i in old_data["Name"]:
18 user = {}
19 user["name"] = i
20 user["email"] = old_data["Email"][index][7:]
21 user["avatar"] = old_data["Avatar"][index]
22 user["description"] = old_data["Description"][index]
23 user["github"] = old_data["Github"][index]
24 user["xda"] = old_data["XDA"][index]
25 user["facebook"] = old_data["Facebook"][index]
26 user["twitter"] = old_data["Twitter"][index]
27 user["instagram"] = old_data["Instagram"][index]
28 user["googleplus"] = old_data["GooglePlus"][index]
29 user_list.append(user)
30 index += 1
31
32# Verify each user
33for i in user_list:
34 print(i)
35
36# Write new JSON
37with open(new_file_name, "w") as write_json:
38 json.dump(user_list, write_json, indent=4)