-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from CUBigDataClass/sagar
multiple stories
- Loading branch information
Showing
38 changed files
with
1,684,880 additions
and
45,085 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,6 @@ | ||
mongodbconfig.py | ||
env.py | ||
*.pyc | ||
pycache/* | ||
pycache/* | ||
node_modules/ | ||
.env |
This file was deleted.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
2000,2017,18,0:36:06.103692 | ||
2020,2021,2,0:03:35.893334 | ||
2021,2020,2,0:03:52.235375 | ||
2000,2021,22,0:26:31.983755 | ||
2000,1980,21,0:25:35.200808 | ||
1979,1960,20,0:24:04.912506 | ||
1959,1950,10,0:12:20.685440 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import os, sys, inspect, json, requests | ||
currentdir = os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe()))) | ||
parentdir = os.path.dirname(currentdir) | ||
sys.path.insert(0, parentdir) | ||
|
||
import env | ||
|
||
|
||
def extract_lat_long_via_location(location): | ||
base_url = "https://maps.googleapis.com/maps/api/geocode/json" | ||
endpoint = f"{base_url}?address={location}&key={env.google_api_key}" | ||
r = requests.get(endpoint) | ||
if r.status_code not in range(200, 299): | ||
return None | ||
try: | ||
''' | ||
This try block incase any of our inputs are invalid. This is done instead | ||
of actually writing out handlers for all kinds of responses. | ||
''' | ||
results = r.json()['results'][0] | ||
latitude = results['geometry']['location']['lat'] | ||
longitude = results['geometry']['location']['lng'] | ||
return latitude, longitude | ||
except: | ||
return None | ||
|
||
|
||
# locations = ['PHILIPSE MANOR HALL (YONKERS, NY)', 'BALDWIN', 'GREAT NECK ESTATES, NY', 'Europe', 'North Pole'] | ||
locations = json.load(open('locations.json', 'r')) | ||
# print(locations) | ||
|
||
start = 0 | ||
# end = 4 | ||
end = len(locations) | ||
locations = locations[start:end] | ||
for index, location in enumerate(locations): | ||
print(f"Fetching location {start + index}") | ||
res = extract_lat_long_via_location(location) | ||
op = f"{index},\"{location}\"," | ||
if res is None: | ||
op += "null,null" | ||
else: | ||
op += f"{res[0]},{res[1]}" | ||
with open('locationres.csv', 'a') as f: | ||
f.write(f"{op}\n") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import geocoder, os, sys, inspect, json | ||
currentdir = os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe()))) | ||
parentdir = os.path.dirname(currentdir) | ||
sys.path.insert(0, parentdir) | ||
|
||
import env | ||
|
||
# locations = ['PHILIPSE MANOR HALL (YONKERS, NY)', 'BALDWIN', 'GREAT NECK ESTATES, NY', 'Europe', 'North Pole'] | ||
locations = json.load(open('locations.json', 'r')) | ||
# print(locations) | ||
|
||
locations = locations[:50] | ||
|
||
g = geocoder.bing(locations, method='batch', key=env.bing_api_key) | ||
res = [] | ||
for result in g: | ||
res.append(result.latlng) | ||
# print(res) | ||
json.dump(res, open('locationres.json', 'w'), indent=2) |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
[ | ||
[ | ||
40.930793762207, | ||
-73.8982925415039 | ||
], | ||
[ | ||
40.6630020141602, | ||
-73.610710144043 | ||
], | ||
[ | ||
40.7853736877441, | ||
-73.7383270263672 | ||
], | ||
[ | ||
54.2612228393555, | ||
17.6698455810547 | ||
], | ||
[ | ||
64.7503356933594, | ||
-147.354187011719 | ||
] | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,199 @@ | ||
[ | ||
[ | ||
32.5399589538574, | ||
-82.9045486450195 | ||
], | ||
[ | ||
40.7130470275879, | ||
-74.0072326660156 | ||
], | ||
[ | ||
38.6353569030762, | ||
-90.2009887695313 | ||
], | ||
[ | ||
39.1720542907715, | ||
-120.139579772949 | ||
], | ||
[ | ||
29.6641635894775, | ||
-95.0192794799805 | ||
], | ||
[ | ||
40.7668914794922, | ||
-73.92138671875 | ||
], | ||
[ | ||
39.9510612487793, | ||
-75.1656188964844 | ||
], | ||
[ | ||
40.6630020141602, | ||
-73.610710144043 | ||
], | ||
[ | ||
-23.6573390960693, | ||
-46.5322494506836 | ||
], | ||
[ | ||
38.6158447265625, | ||
-122.871940612793 | ||
], | ||
[ | ||
40.930793762207, | ||
-73.8982925415039 | ||
], | ||
[ | ||
32.7830619812012, | ||
-79.934440612793 | ||
], | ||
[ | ||
22.345308303833, | ||
76.2188339233398 | ||
], | ||
[ | ||
18.9492219805194, | ||
72.8232993261008 | ||
], | ||
[ | ||
40.8095054626465, | ||
-73.9635238647461 | ||
], | ||
[ | ||
40.7853736877441, | ||
-73.7383270263672 | ||
], | ||
[ | ||
32.842155456543, | ||
-104.401077270508 | ||
], | ||
[ | ||
40.8875923156738, | ||
-72.9422378540039 | ||
], | ||
[ | ||
40.7471361500429, | ||
-73.9779305502094 | ||
], | ||
[ | ||
51.1455917358398, | ||
-120.116546630859 | ||
], | ||
[ | ||
48.6476936340332, | ||
-118.73804473877 | ||
], | ||
[ | ||
30.4488182067871, | ||
-96.6569213867188 | ||
], | ||
[ | ||
-27.4830551147461, | ||
153.00666809082 | ||
], | ||
[], | ||
[ | ||
46.7779655456543, | ||
-56.1783142089844 | ||
], | ||
[ | ||
40.795970916748, | ||
-74.4944839477539 | ||
], | ||
[ | ||
41.0712776184082, | ||
-72.3392105102539 | ||
], | ||
[ | ||
40.5339622497559, | ||
-74.173828125 | ||
], | ||
[ | ||
0.0401530005037785, | ||
-51.056957244873 | ||
], | ||
[ | ||
31.9490756988525, | ||
-81.311653137207 | ||
], | ||
[ | ||
50.2114372253418, | ||
-5.48076105117798 | ||
], | ||
[ | ||
41.0282974243164, | ||
-75.6701889038086 | ||
], | ||
[ | ||
40.895637512207, | ||
71.7276916503906 | ||
], | ||
[ | ||
-26.2129383087158, | ||
28.1638259887695 | ||
], | ||
[ | ||
46.2218055725098, | ||
15.3103542327881 | ||
], | ||
[ | ||
51.0931243896484, | ||
10.3802080154419 | ||
], | ||
[ | ||
41.6258201599121, | ||
-74.7402038574219 | ||
], | ||
[ | ||
44.4759902954102, | ||
-73.2109985351563 | ||
], | ||
[ | ||
17.00599, | ||
99.82669 | ||
], | ||
[ | ||
34.0522384643555, | ||
-118.243347167969 | ||
], | ||
[ | ||
43.4570465087891, | ||
-71.2216796875 | ||
], | ||
[ | ||
39.8280309129997, | ||
-77.2365792157431 | ||
], | ||
[ | ||
40.7204170227051, | ||
-73.7432327270508 | ||
], | ||
[ | ||
40.8527565002441, | ||
-74.0431671142578 | ||
], | ||
[ | ||
38.5467262268066, | ||
-121.744338989258 | ||
], | ||
[ | ||
38.4847297668457, | ||
-98.3801803588867 | ||
], | ||
[ | ||
42.4404945373535, | ||
-76.4957046508789 | ||
], | ||
[ | ||
40.4421691894531, | ||
-79.9949569702148 | ||
], | ||
[ | ||
42.5171356201172, | ||
-82.9255218505859 | ||
], | ||
[ | ||
36.7316551208496, | ||
-119.785858154297 | ||
] | ||
] |
Oops, something went wrong.