Skip to content

Commit 8bd8025

Browse files
committed
Update main.py with better file error handling, remove comments, standardize exceptions.
1 parent 77cedb5 commit 8bd8025

File tree

1 file changed

+11
-14
lines changed

1 file changed

+11
-14
lines changed

main.py

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def get_input():
2020
else:
2121
print("Invalid value. Enter either a 1 or 2 to continue.")
2222
except ValueError:
23-
print("Invalid value enter a 1 or 2 to continue.")
23+
print("Invalid value. Enter either a 1 or 2 to continue.")
2424

2525

2626
def generate_output(n):
@@ -35,14 +35,15 @@ def generate_output(n):
3535
" "
3636
)
3737
if inputfile.endswith(".csv") and outputfile.endswith(".csv"):
38-
with open(inputfile, "r") as infile, open(outputfile, "w", newline='') as outfile:
39-
reader = csv.reader(infile)
40-
writer = csv.writer(outfile)
41-
for row in reader:
42-
parsed_sig = SigParser().parse(row[0])
43-
writer.writerow([parsed_sig])
44-
print(f"Output written to {outputfile}")
45-
break
38+
with open(inputfile, "r") as infile:
39+
with open(outputfile, "w", newline='') as outfile:
40+
reader = csv.reader(infile)
41+
writer = csv.writer(outfile)
42+
for row in reader:
43+
parsed_sig = SigParser().parse(row[0])
44+
writer.writerow([parsed_sig])
45+
print(f"Output written to {outputfile}")
46+
break
4647
else:
4748
print("Both files must end with .csv. Please try again.")
4849
except ValueError:
@@ -53,8 +54,4 @@ def generate_output(n):
5354

5455

5556
if __name__ == "__main__":
56-
main()
57-
58-
59-
# parsed_sig = SigParser().parse(x)
60-
# print(parsed_sig)
57+
main()

0 commit comments

Comments
 (0)