Last active
April 9, 2023 15:45
-
-
Save JamesIgoe/747f8a46393ce9622f970014879b2ec9 to your computer and use it in GitHub Desktop.
Example code to generate JSON from 2 prior lists. Pulled from code that takes 2 DataFrames, one that list members to a add, and one that includes members to remove, then generates nested JSON.
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 pandas as pd | |
import json | |
memberChange = [] | |
for email in df_add.values: | |
try: | |
if email: | |
memberChange.append({'Email': email[0], 'MemberName': '', 'MemberType': 'Person', 'Action': 'Add'}) | |
except: | |
pass | |
for email in df_remove.values: | |
try: | |
if email: | |
memberChange.append({'Email': email[0], 'MemberName': '', 'MemberType': 'Person', 'Action': 'Remove'}) | |
except: | |
pass | |
data = {} | |
data['GroupName'] = group_name | |
data['ManagerName'] = manager_name | |
data['Members'] = memberChange | |
json_data = json.dumps(data) | |
print(json_data) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment