-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcompress_output.py
26 lines (23 loc) · 950 Bytes
/
compress_output.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import os
import json
import argparse
def compress_ouput(filename="outputs.json", output_folder="phase2_outputs/"):
with open(filename, 'w') as output_json:
data = {}
for output in os.listdir(output_folder):
with open(output_folder + output, 'r') as output_file:
if output[-4:] == '.out':
string = ''
for l in output_file.readlines():
string += l
data[output] = string
output_json.write(json.dumps(data))
"""
Run `python3 compress_outputs.py <path to output folder>` and submit the 'outputs.json'
that is created to gradescope.
"""
if __name__ == '__main__':
parser = argparse.ArgumentParser(description='Parsing arguments')
parser.add_argument('outputs', type=str, help='The path to the output file or directory')
args = parser.parse_args()
compress_ouput(output_folder=args.output)