import json import pandas as pd split = 'genre' with open(f"./results-{split}/app_list.txt", "r") as f: APP_LIST = [line.strip() for line in f.readlines()] with open("./cat_apps-full.json", "r") as f: CAT_APPS = json.load(f) for cat, apps in CAT_APPS.items(): CAT_APPS[cat] = [app for app in apps if str(app) in APP_LIST] CAT_APPS = {k:v for k,v in CAT_APPS.items() if k != 'VR' and len(v) > 0} CAT_APPS['All'] = [int(app) for app in APP_LIST] with open(f"./cat_apps-{split}.json", "w") as f: json.dump(CAT_APPS, f, indent=4)