import json from tqdm import tqdm import typer def preprocess(data_path, processed_data_path): with open(data_path) as f: data = json.loads(f.read()) with open(processed_data_path, "w") as f: for grant in tqdm(data["grants"]): if any( [ org["name"] == "The Wellcome Trust" for org in grant["fundingOrganization"] ] ): f.write(json.dumps(grant) + "\n") if __name__ == "__main__": typer.run(preprocess)