Skip to content

Commit

Permalink
Update converter.py
Browse files Browse the repository at this point in the history
  • Loading branch information
bielacki authored Feb 26, 2021
1 parent cdb2f9b commit 59f6315
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,18 @@
with open('666.json','r') as f:
data = json.loads(f.read())

elements = ["tag", "trigger", "variable", "builtInVariable", "folder", "zone", "customTemplate"]
tabs = []

for el in elements:
if el in data["containerVersion"].keys():
tabs.append(el)
elements = {"tag": "Tags",
"trigger": "Triggers",
"variable": "User-Defined Variables",
"builtInVariable": "Built-In Variables",
"folder": "Folders",
"zone": "Zones",
"customTemplate": "Templates"}

# Change the name of the final xlsx file, if necessary
with pd.ExcelWriter('output-GTM.xlsx') as writer:
for i in tabs:
pd.json_normalize(data["containerVersion"][i]).to_excel(writer, sheet_name=i, index=False)
for i in elements:
if i in data["containerVersion"].keys():
pd.json_normalize(data["containerVersion"][i]).to_excel(writer, sheet_name=elements[i], index=False)

print("Done.")

0 comments on commit 59f6315

Please sign in to comment.