Skip to content

Instantly share code, notes, and snippets.

@vinx13
Last active November 7, 2018 08:06
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vinx13/6c9231843a5833f31de7eab938b345b1 to your computer and use it in GitHub Desktop.
Save vinx13/6c9231843a5833f31de7eab938b345b1 to your computer and use it in GitHub Desktop.
import argparse
import json
parser = argparse.ArgumentParser()
parser.add_argument('in_file', type=str)
parser.add_argument('out_file', type=str)
args = parser.parse_args()
def transform(line):
if line.startswith('#'):
return line.strip()
record = json.loads(line)
dilation = [1, 1]
workload = record['i'][4]
workload.insert(5, dilation)
record['i'][4] = workload
args = record['i'][2]
args.insert(4, dilation)
record['i'][2] = args
return json.dumps(record)
if __name__=='__main__':
with open(args.in_file) as f:
lines = f.readlines()
lines = map(transform, lines)
with open(args.out_file, 'w') as f:
for line in lines:
f.write(line)
f.write('\n')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment