I'm trying to interpret this JSON file but I couldn't figure it out.
{"results": [{"fsq_id": "4dc586fbcc3ff3b3045e2ef3","categories": [{"id": 17056,"name": "Flower Store","icon": {"prefix": "https://ss3.4sqi.net/img/categories_v2/shops/flowershop_","suffix": ".png"}}],"chains": [],"distance": 121,"geocodes": {"main": {"latitude": 60.24277,"longitude": 24.92642}},"location": {"address": "Pakilantie 69","country": "FI","locality": "Helsinki","postcode": "00660","region": "Uusimaa"},"name": "Pakilan Kukkatalo","related_places": {},"timezone": "Europe/Helsinki"},{"fsq_id": "4d972d612bd6f04de0524850","categories": [{"id": 18064,"name": "Soccer Field","icon": {"prefix": "https://ss3.4sqi.net/img/categories_v2/arts_entertainment/stadium_soccer_","suffix": ".png"}}],"chains": [],"distance": 149,"geocodes": {"main": {"latitude": 60.24221613213154,"longitude": 24.929252754506127}},"location": {"address": "Pakila","country": "FI","cross_street": "","locality": "Helsinki","postcode": "","region": "Uusimaa"},"name": "HPS-halli","related_places": {},"timezone": "Europe/Helsinki"},{"fsq_id": "4f88508ae4b00a6260d51c09","categories": [{"id": 13016,"name": "Lounge","icon": {"prefix": "https://ss3.4sqi.net/img/categories_v2/nightlife/default_","suffix": ".png"}}],"chains": [],"distance": 177,"geocodes": {"main": {"latitude": 60.24322,"longitude": 24.925877}},"location": {"country": "FI","cross_street": "","postcode": ""},"name": "Vuokrasauna.fi","related_places": {},"timezone": "Europe/Helsinki"},{"fsq_id": "4c097ac53c70b713fdd3275b","categories": [{"id": 17069,"name": "Grocery Store / Supermarket","icon": {"prefix": "https://ss3.4sqi.net/img/categories_v2/shops/food_grocery_","suffix": ".png"}}],"chains": [],"distance": 280,"geocodes": {"main": {"latitude": 60.239423847583105,"longitude": 24.929011346258985}},"location": {"address": "Pakilantie 61","country": "FI","locality": "Helsinki","postcode": "00660","region": "Uusimaa"},"name": "S-market Pakila","related_places": {"children": []},"timezone": "Europe/Helsinki"},{"fsq_id": "5177bebce4b036dbba157074","categories": [{"id": 17082,"name": "Furniture and Home Store","icon": {"prefix": "https://ss3.4sqi.net/img/categories_v2/shops/furniture_","suffix": ".png"}}],"chains": [],"distance": 282,"geocodes": {"main": {"latitude": 60.24412692651818,"longitude": 24.92534364400254}},"location": {"address": "Elontie 71","country": "FI","cross_street": "","locality": "Helsinki","postcode": "00660","region": "Uusimaa"},"name": "Parkettilattiat Oy","related_places": {},"timezone": "Europe/Helsinki"},{"fsq_id": "4e95b46e9adfced1a955a6e1","categories": [{"id": 17035,"name": "Drugstore","icon": {"prefix": "https://ss3.4sqi.net/img/categories_v2/shops/pharmacy_","suffix": ".png"}}],"chains": [],"distance": 388,"geocodes": {"main": {"latitude": 60.23825881820312,"longitude": 24.928175247924628}},"location": {"address": "Pakilantie 56","country": "FI","cross_street": "","locality": "Helsinki","postcode": "00660","region": "Uusimaa"},"name": "Pakilan Apteekki","related_places": {},"timezone": "Europe/Helsinki"},{"fsq_id": "5184e1f3498ef45e57b9a417","categories": [{"id": 13034,"name": "Caf\u00e9","icon": {"prefix": "https://ss3.4sqi.net/img/categories_v2/food/cafe_","suffix": ".png"}},{"id": 13065,"name": "Restaurant","icon": {"prefix": "https://ss3.4sqi.net/img/categories_v2/food/default_","suffix": ".png"}}],"chains": [],"distance": 438,"geocodes": {"main": {"latitude": 60.237879766432634,"longitude": 24.928877151037955}},"location": {"address": "Pakilantie 55","country": "FI","cross_street": "Osuuskunnantie","locality": "Helsinki","postcode": "00660","region": "Uusimaa"},"name": "Kahvila Helmi","related_places": {},"timezone": "Europe/Helsinki"},{"fsq_id": "58ab1e4826a4075f5fa3a891","categories": [{"id": 13012,"name": "Hookah Bar","icon": {"prefix": "https://ss3.4sqi.net/img/categories_v2/nightlife/hookahbar_","suffix": ".png"}}],"chains": [],"distance": 366,"geocodes": {"main": {"latitude": 60.239296,"longitude": 24.922197}},"location": {"country": "FI","cross_street": "","postcode": ""},"name": "Noora's","related_places": {},"timezone": "Europe/Helsinki"},{"fsq_id": "58296da35cc1d73f7580d214","categories": [{"id": 13334,"name": "Sandwich Restaurant","icon": {"prefix": "https://ss3.4sqi.net/img/categories_v2/food/deli_","suffix": ".png"}}],"chains": [],"distance": 369,"geocodes": {"main": {"latitude": 60.238425,"longitude": 24.928056}},"location": {"address": "Pakilantie 56","country": "FI","cross_street": "","locality": "Helsinki","postcode": "00660","region": "Uusimaa"},"name": "House of Sandwiches","related_places": {},"timezone": "Europe/Helsinki"},{"fsq_id": "4c52d3d9989eb7137441b226","categories": [{"id": 17069,"name": "Grocery Store / Supermarket","icon": {"prefix": "https://ss3.4sqi.net/img/categories_v2/shops/food_grocery_","suffix": ".png"}}],"chains": [{"id": "e5a2fd48-9989-4012-a8e4-45404edc24e6","name": "R-Kioski"}],"distance": 385,"geocodes": {"main": {"latitude": 60.23828070026192,"longitude": 24.928105045660168}},"location": {"address": "Pakilantie 56","country": "FI","locality": "Helsinki","postcode": "00660","region": "Uusimaa"},"name": "R-Kioski","related_places": {},"timezone": "Europe/Helsinki"},{"fsq_id": "4cce9331ba0a548127874959","categories": [{"id": 13064,"name": "Pizzeria","icon": {"prefix": "https://ss3.4sqi.net/img/categories_v2/food/pizza_","suffix": ".png"}},{"id": 13145,"name": "Fast Food Restaurant","icon": {"prefix": "https://ss3.4sqi.net/img/categories_v2/food/fastfood_","suffix": ".png"}}],"chains": [],"distance": 465,"geocodes": {"main": {"latitude": 60.24571426909511,"longitude": 24.924457646189502}},"location": {"address": "Pakilantie 82","country": "FI","cross_street": "Ripusuontie","locality": "Helsinki","postcode": "00660","region": "Uusimaa"},"name": "Pakilan Pizza-Kebab","related_places": {},"timezone": "Europe/Helsinki"}],"context": {"geo_bounds": {"circle": {"center": {"latitude": 60.241687,"longitude": 24.9267659},"radius": 500}}}
}
I want to get 'name'
, "latitude"
, "longitude"
, and 'categories'
.
I tried this code but it didn't work:
def getNearbyVenues(names, latitudes, longitudes, radius=500):headers = {"Accept": "application/json","Authorization": "fsq363333333###JtJOrcBK3WguBrzyryQuTrO3hhhsFMzZ3CJo="}URL = "https://api.foursquare.com/v3/places/search?ll={},{}&radius={}&limit={}"venues_list = []for name, lat, lng in zip(names, latitudes, longitudes):print(name)url = URL.format(lat, lng, radius, LIMIT)results = requests.request("GET", url, headers=headers).json()['results']['main'][0]['location']venues_list.append([(name,lat,lng,v['venue']['name'],v['venue']['location']['lat'],v['venue']['location']['lng'],v['venue']['categories'][0]['name']) for v in results])nearby_venues = pd.DataFrame([item for venue_list in venues_list for item in venue_list])nearby_venues.columns = ['Neighborhood','Neighborhood Latitude','Neighborhood Longitude','Venue','Venue Latitude','Venue Longitude','Venue Category']return(nearby_venues)
What should I edit so it works?