Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
drgnfrts
GitHub Repository: drgnfrts/Singapore-Locations-NER
Path: blob/main/archive/unclean_locations_data/json_mergerer.py
744 views
1
import json
2
3
files = ['../data/extracted_locations/extracted_lrt_stns.json',
4
'../data/extracted_locations/extracted_mrt_stns.json',
5
'../data/extracted_locations/short_manual_buildings_name_list.json',
6
'../data/extracted_locations/extracted_buildings_address_list.json',
7
'../data/extracted_locations/extracted_buildings_postcode.json',
8
'../data/extracted_locations/extracted_road_names_list.json',
9
'../data/extracted_locations/extracted_subzones.json'
10
]
11
12
13
def merge_JsonFiles(filename):
14
result = list()
15
for f1 in filename:
16
with open(f1, 'r') as infile:
17
result.extend(json.load(infile))
18
19
list(set(result))
20
21
with open('../data/extracted_locations/combined_locations.json', "w", encoding="utf-8") as f:
22
json.dump(result, f, indent=4)
23
24
25
merge_JsonFiles(files)
26
27