-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathconvertToMyConventionJson.py
48 lines (38 loc) · 1.06 KB
/
convertToMyConventionJson.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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import json
def makeObj(gu, la, en, pu):
return {
'line': {
"gurmukhi": {
"unicode": gu
},
"larivaar": {
"unicode": la
},
"translation": {
"english": {
"default": en
},
"punjabi": {
"default": {
"unicode": pu
}
}
}
}
}
with open('C:\\Users\\harde\\Downloads\\dukh.json', encoding="utf8") as f:
_file = json.load(f)
json_file = _file['verses']
new_json = []
for i in json_file:
new_json.append(makeObj(i['verse']['verse']['unicode'], i['verse']['larivaar']['unicode'], i['verse']
['translation']['en']['bdb'], i['verse']['translation']['pu']['ss']['unicode']))
complete_json = {
'baniinfo': {
'id': 8,
'unicode': _file['baniInfo']['unicode'],
},
'bani': new_json
}
with open('dukh.json', 'w') as f:
json.dump(complete_json, f)