Created
March 29, 2018 04:49
-
-
Save csarron/73a096d2b92ee4ec3065cd4f3923591a to your computer and use it in GitHub Desktop.
format json for better text editor loading
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
import argparse | |
import json | |
parser = argparse.ArgumentParser() | |
parser.add_argument('--input', type=str, default='your.json') | |
args = parser.parse_args() | |
# Read dataset | |
with open(args.input) as f: | |
dataset = json.load(f) | |
# Iterate and write question-answer pairs | |
count = 0 | |
with open(args.input + '.json', 'w') as fo: | |
fo.write(json.dumps(dataset, indent=4, sort_keys=True)) | |
fo.write('\n') | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment