This codebase is being used to gather and analyze data for places we might like to live around Boston, MA. Essentially, we use Python and several API's including Yelp and Google to collect information into a SQLite database, where further analysis can be done. For the sake of this project, we will provide the finished product of the database file (NextHome_database.db) in addition to the Python scripts interacting with the API's.
Documentation and links to various helpful components:
Google Maps - Distance Matrix API documentation
Google Maps - Places API Web Service documentation
MA 2016 Presidential Voting Data By City
As mentioned, we will try to keep the database up-to-date with some of the latest info. We'll include queries that can be run on the data in a file called report1.sql. Also, we recommend installing the program DB Browser for SQLite to see into NextHome_database.db.
Before doing anything else, run the following to install the dependencies:
pip install -r requirements.txt
.
To run the code without specifying any arguments (thereby utilizing the DEFAULT values we altered):
python sample.py
. Alternatively, run the code sample by specifying the optional arguments:
python sample.py --term="bars" --location="San Francisco, CA"
Specifically, we've used the following files to pull information python yelp_api_to_json.py
with optional parameters.
Then to get into SQLite database use python yelptosql.py
.
The first API calls we made were to determine how long morning commutes would be, via the Distance Matrix API. Just run python Google_Distance_Matrix_API.py
to compile for all towns in MA against the target destination (Boston) to arrive by 8 a.m. It would definitely be possible to generalize the code and accept command-line inputs.
The next two files work in tandem to find Places of interest via the Place Search API. First python Google_Geolocate.py
runs through the Towns list for MA to generate latitude and longitude, then python Google_places_by_town.py
does API calls first for placeids for Places of Interest then finds details about the business with additional searches.
The queries in report1.sql
are meant to run successfully against the SQLite file NextHome_database.db
. No doubt there are minor alterations that we may make in the data post-insertion, which may not be included in report1.sql
. Items that come to mind: deduping, replacing any '+' signs with regular spaces, etc. If issues are ever reported regarding these minor alterations that I performed manually, we could add commands into a new SQL file.