Last active
November 7, 2018 08:06
-
-
Save vinx13/6c9231843a5833f31de7eab938b345b1 to your computer and use it in GitHub Desktop.
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('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