[Solved] How to parse a JSON file? [closed]

Here is a Python program that performs the conversion you ask for. Copy this code into a file called, for example, “convert.py”. You can then run the program like so:

python convert.py my_existing_file.json my_new_file.txt

Here is the program:

import argparse
import json

# Get filenames from user
parser = argparse.ArgumentParser()
    'input', type=argparse.FileType('r'), help="input JSON filename")
    'output', type=argparse.FileType('w'), help="output 2-col text filename")
args = parser.parse_args()

# Read data in
data = json.load(args.input)

# Convert data to abstracted format
data = [[d["diagnoses"][0]["tumor_stage"], d["case_id"]] for d in data]

# Write the data out:
for d in data:

solved How to parse a JSON file? [closed]