Spaces:
Sleeping
Sleeping
File size: 734 Bytes
12ae336 9b744c5 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
"""
Module which builds a dictionary keyed by issue number from a json file
"""
import argparse
import json
def build_json_file(input_filename, output_filename):
with open(input_filename, "r") as f:
json_lines = f.readlines()
issues = [json.loads(line) for line in json_lines]
json_dict = {issue["number"]: issue for issue in issues}
with open(output_filename, "w") as f:
json.dump(json_dict, f, indent=4)
if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument("--input_filename", type=str, default="issues.json")
parser.add_argument("--output_filename", type=str, default="issues_dict.json")
args = parser.parse_args()
build_json_file(**vars(args))
|