-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfun.py
More file actions
62 lines (52 loc) · 1.15 KB
/
fun.py
File metadata and controls
62 lines (52 loc) · 1.15 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
import requests
import json
from time import sleep
def nonblank_lines(f):
for l in f:
line = l.strip()
if line:
yield line
if __name__ == "__main__":
with open('cities.txt', 'r') as f_in:
for line in nonblank_lines(f_in):
line = line.split()
currState = line[0]
currCity = ''
if(len(line[1:]) > 1):
for x in line[1:]:
currCity += x + ' '
else:
currCity = line[1:][0]
print(currState)
print(currCity)
raw_url = "https://maps.googleapis.com/maps/api/geocode/json?address="
city = currCity
state = currState
key = "AIzaSyAt3K6rCaD_TyMWvixrPGi4sG1Ky-8deVU"
strToFind = 'lat'
r = requests.get(raw_url + "+" +city + ",+" + state + "&" + key)
print(str(r.json()).find(strToFind))
try:
sleep(.5)
#lat_lng = r.json()["results"][0]["geometry"]["location"]
except:
print('getting here')
print(r.json())
lat = lat_lng["lat"]
lng = lat_lng["lng"]
print(lat, lng)
"""
f = open('cities.txt', 'r')
count = 0
for i in range(1000):
#print(count)
count += 1
if count % 2 == 1:
continue
else:
current = f.readline()
print(current)
for i in range(1000):
for x in
print(f.read())
"""