forked from metaodi/artmap
-
Notifications
You must be signed in to change notification settings - Fork 1
/
merge.py
34 lines (27 loc) · 851 Bytes
/
merge.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
#!/usr/bin/python
# Copyright (c) 2013 Julius Chronak. You can use this source code
# under the terms of the MIT License found in the LICENSE file:
#
# https://raw.github.com/julochrobak/streetscleaner/master/LICENSE
from pprint import pprint
import os.path
import json
sep = ''
with open('output.json', 'w') as out:
out.write('var elems = {\n')
out.write(' "type": "FeatureCollection",\n')
out.write(' "features": [\n')
for filename in os.listdir('output/'):
if not filename.endswith(".json"):
continue
print(filename)
with open('output/' + filename) as f:
try:
d = json.load(f)
out.write('\n' + sep)
json.dump(d, out)
sep = ','
except:
pass
f.close()
out.write(' ]}\n')