Last active
June 26, 2024 21:00
-
-
Save tashrifbillah/f8451473a78b639e828c42fe419d029c to your computer and use it in GitHub Desktop.
Reorder charts on DPdash
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
#!/usr/bin/env python | |
import json | |
reordered='/data/predict1/charts1.json' | |
raw='/data/predict1/predict-mongodb-backup/charts_20240612.json' | |
# find out the private charts in raw | |
# print 0-indexed indices of private charts from raw file | |
with open(reordered) as f: | |
charts=f.read().strip().split('\n') | |
reordered=[] | |
for c in charts | |
reordered.append(json.loads(c)) | |
with open(raw) as f: | |
charts=f.read().strip().split('\n') | |
raw=[] | |
for c in charts | |
raw.append(json.loads(c)) | |
# iterate through reordered | |
# look for (title,owner) pair in raw | |
# if it does not exist, print index | |
# Dheshan will complete this code |
cc @dheshanm
I have the completed code here:
import json
reordered_path = "/data/predict1/charts1.json"
raw_path = "/data/predict1/predict-mongodb-backup/charts_20240612.json"
from typing import List, Tuple
reordered = []
reordered_tuples: List[Tuple[str, str]] = []
with open(reordered_path) as f:
charts = f.read().strip().split("\n")
for c in charts:
chart = json.loads(c)
chart_title = chart["title"]
chart_owner = chart["owner"]
reordered_tuples.append((chart_title, chart_owner))
reordered.append(chart)
# look for (title,owner) pair in raw
# if it does not exist, print index
with open(raw_path) as f:
charts = f.read().strip().split("\n")
for idx, c in enumerate(charts):
chart = json.loads(c)
chart_title = chart["title"]
chart_owner = chart["owner"]
if (chart_title, chart_owner) not in reordered_tuples:
print(idx)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
cc @sbouix