-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjson-formatter.py
More file actions
31 lines (27 loc) · 888 Bytes
/
Copy pathjson-formatter.py
File metadata and controls
31 lines (27 loc) · 888 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
27
28
29
30
31
def Reverse(lst):
new_lst = lst[::-1]
return new_lst
with open("input.txt", "r", encoding="utf-8") as f:
lines = f.readlines()
lines_list = []
for i in lines:
temp = i.replace("\n\n\n", "")
lines_list.insert(0, temp)
lines = Reverse(lines_list)
properties = []
descriptions = []
count = 0
for i in lines:
if (count % 2 == 0):
properties.insert(0, i.replace("\n", ""))
else:
descriptions.insert(0, i.replace("\n", ""))
count += 1
properties = Reverse(properties)
descriptions = Reverse(descriptions)
with open("output.json", "w", encoding="utf-8") as r:
print(str('['), file=r)
for a in range(0, len(properties)):
print("{ \"property\": \"" +
properties[a] + "\",\n \"Description\": \"" + descriptions[a] + "\"},", file=r)
print(str(']'), file=r)