-
Notifications
You must be signed in to change notification settings - Fork 1
/
nomesRuas.py
executable file
·71 lines (52 loc) · 1.79 KB
/
nomesRuas.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#!/usr/bin/env python
import numpy
import unicodedata
import sys, getopt
# local
from pmj_osm_utils import *
def main(argv):
inputfile = ''
outputfile = ''
try:
opts, args = getopt.getopt(argv,"hi:o:",["ifile=","ofile="])
except getopt.GetoptError:
print('-i <inputfile> -o <outputfile>')
sys.exit(2)
for opt, arg in opts:
if opt == '-h':
print('-i <inputfile> -o <outputfile>')
sys.exit()
elif opt in ("-i", "--ifile"):
inputfile = arg
elif opt in ("-o", "--ofile"):
outputfile = arg
print('Input file is', inputfile)
print('Output file is', outputfile)
nomesRuas = open(inputfile, 'r').read().splitlines()
nomesRuas = list(set(nomesRuas))
osmStreetName = dict()
for line in nomesRuas:
line = line.rstrip()
if line in osmStreetName.values():
continue
primitiveName = simplifyAddress(line)
if primitiveName in osmStreetName.keys():
print(primitiveName + ' ja existe! ' + line)
exit()
osmStreetName[primitiveName] = line
print(primitiveName + ' ' + line)
oldName = primitiveName
primitiveName = primitiveName.replace('’','')
primitiveName = primitiveName.replace('-',' ')
if oldName != primitiveName and primitiveName in osmStreetName.keys():
print(primitiveName + ' ja existe! ' + line)
exit()
if oldName != primitiveName:
osmStreetName[primitiveName] = line
print(primitiveName)
print(primitiveName + ' ' + line)
for key, value in osmStreetName.items():
print(key + " -> " + value)
numpy.save(outputfile, osmStreetName)
if __name__ == "__main__":
main(sys.argv[1:])