-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathboltman.py
29 lines (22 loc) · 831 Bytes
/
boltman.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
27
28
29
# read boltman.csv and print the contents
with open('boltman.csv', 'r') as f:
lines = f.readlines()
for i in range(len(lines)):
if lines[i].endswith('\n'):
lines[i] = lines[i][:-1]
if lines[i].endswith('\'') or lines[i].endswith('\"'):
lines[i] = lines[i][:-1]
if lines[i].startswith('\'') or lines[i].startswith('\"'):
lines[i] = lines[i][1:]
printStr = "["
for i in range(len(lines)):
ln = lines[i]
# replace all single quotes with "\'" in ln
# replace all double quotes with "\"" in ln
ln = ln.replace("\'", "\\\'")
ln = ln.replace("\"", "\\\"")
if i != len(lines) - 1:
printStr += "\"" + ln + "\"" + ","
else:
printStr += "\"" + ln + "\"" + "]"
print(printStr)