Skip to content

Commit

Permalink
allow optional argument
Browse files Browse the repository at this point in the history
  • Loading branch information
teuben committed Aug 22, 2023
1 parent d0f6871 commit 5cbcbc4
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions write_problems.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,18 @@
#! /usr/bin/env python
import sys
from re import match
from aparser import parse_generic as parse
import json

file = open('inputs.txt', 'r')
ofile ="athena_problems.json"

if len(sys.argv) > 1:
ifile = sys.argv[1]
else:
ifile = 'inputs.txt'

file = open(ifile, 'r')
print("input: ",ifile)

line = file.readline()

Expand Down Expand Up @@ -33,7 +42,8 @@
json_object = json.dumps(dict, indent=3)

# Writing to sample.json
with open("athena_problems.json", "w") as outfile:
with open(ofile, "w") as outfile:
outfile.write(json_object)

file.close()
file.close()
print("output:",ofile)

0 comments on commit 5cbcbc4

Please sign in to comment.