-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathutils.py
More file actions
26 lines (24 loc) · 758 Bytes
/
utils.py
File metadata and controls
26 lines (24 loc) · 758 Bytes
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
# prints to screen an array of strings by surrounding them in a frame
def program_header(elements):
elements.insert(len(elements), "")
elements.insert(0, "")
longest = 0
sep = "#"
for elm in elements:
if len(elm) > longest:
longest = len(elm)
print(sep * (longest + 4))
for elm in elements:
print(sep + " " + elm + " " * (longest - len(elm)) + " " + sep)
print(sep * (longest + 4))
# saves an array of strings to the file in SAVE_FILE_PATH by appending a the array as a comma separated values line
def save_to_csv_file(elements, path):
CSV_SEPARATOR = ";"
out_file = open(path, "a")
cs = ""
for index, el in enumerate(elements):
if index == len(elements) - 1:
cs += el
else:
cs += el + CSV_SEPARATOR
out_file.write(cs + "\n")