forked from FIWARE/data-models
-
Notifications
You must be signed in to change notification settings - Fork 0
/
stations.py
executable file
·45 lines (33 loc) · 1.17 KB
/
stations.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
#!bin/python
# -*- coding: utf-8 -*-
import csv
def main():
csvoutput = open('stations-normalized.csv', 'wb')
station_writer = csv.writer(csvoutput, delimiter=',')
with open('stations.csv', 'rU') as csvfile:
reader = csv.reader(csvfile, delimiter=';')
index = 0
for row in reader:
if index != 0:
latitude = row[5].strip()
longitude = row[6].strip()
out_latitude = ''
out_longitude = ''
out_latitude = latitude[0:2]
out_latitude += ' '
out_latitude += latitude[2:4]
out_latitude += ' '
out_latitude += latitude[4:6]
if longitude[6] == 'W':
out_longitude = '-'
out_longitude += longitude[0:2]
out_longitude += ' '
out_longitude += longitude[2:4]
out_longitude += ' '
out_longitude += longitude[4:6]
row[5] = out_latitude
row[6] = out_longitude
station_writer.writerow(row)
index += 1
if __name__ == '__main__':
main()