-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpair_sing_sic_subs.py
More file actions
75 lines (68 loc) · 1.83 KB
/
pair_sing_sic_subs.py
File metadata and controls
75 lines (68 loc) · 1.83 KB
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# coding=utf-8
"""Load substation lists and write files with csv format."""
import json
FILE1 = 'substation_locs/sub_sig_20181016234836.json'
FILE2 = 'substation_locs/sub_sing_20181016234836.json'
def one_record(feat):
"""Get one output line."""
one = feat['properties']
geo = feat['geometry']
return ','.join([
one['nombre'],
one['propiedad'],
one['tension_kv'],
one['tipo'],
one['f_operacio'],
one['rca'],
one['sist_elect'],
one['estado'],
one['coord_este'],
one['coord_nort'],
one['huso'],
one['datum'],
one['region'],
one['provincia'],
one['comuna'],
one['fuente_bas'],
one['fech_crea'],
one['fech_act'],
str(geo['coordinates'][0]),
str(geo['coordinates'][1]),
])
def main():
"""Main run point."""
with open(FILE1) as file1:
loaded1 = json.load(file1)
with open(FILE2) as file2:
loaded2 = json.load(file2)
with open('outputfile.csv', 'w') as outfile:
outfile.write(','.join([
'nombre',
'propiedad',
'tension_kv',
'tipo',
'f_operacio',
'rca',
'sist_elect',
'estado',
'coord_este',
'coord_nort',
'huso',
'datum',
'region',
'provincia',
'comuna',
'fuente_bas',
'fech_crea',
'fech_act',
'coordinates_1',
'coordinates_2',
]))
for feat in loaded1['features']:
outfile.write(one_record(feat))
outfile.write('\n')
for feat in loaded2['features']:
outfile.write(one_record(feat))
outfile.write('\n')
if __name__ == '__main__':
main()