<jupyter_start><jupyter_text>Client ID<KEY>4MSriJZOVqZN2Qzr5VJv7ZNFM7XiPtcSA-EmXpB-Pp4eoJi-xfOoFNFHb2A6g0-TWApA6Xeieg9bL8erXqdvBlfnLCGJhnh8p8QEa_UWgKGrnSr4dJgOgNQDcPt7XnYx<jupyter_code>#Dependencies
import pandas as pd
import requests
import numpy as np
import matplotlib.pyplot as plt
import geojson as gs
from ipyleaflet import Map, Marker, MarkerCluster
from IPython.core.display import display, HTML
import pymongo
from pymongo import MongoClient
print ('Mongo version', pymongo.__version__)
client = MongoClient('localhost', 27017)
db = client.test
collection = db.people

base_url = "https://api.yelp.com/v3/businesses/search"

yelp_headers = {
    "Authorization": "Bearer <KEY>"
}<jupyter_output><empty_output><jupyter_text>Take Out & Delivery in San Francisco, CA<jupyter_code>yelp_params = {
    "term": "delivery",
    "location": "San Francisco, CA", 
    "limit": 50,
    "radius": 20000   
}
#Perform API Key request.
response = requests.get(base_url, params=yelp_params, headers=yelp_headers)
response

sf_data = response.json()
sf_data<jupyter_output><empty_output><jupyter_text>API request using 'Transactions'<jupyter_code>sf_transactions_base_url = "https://api.yelp.com/v3/transactions/delivery/search"
response = requests.get(sf_transactions_base_url, params=yelp_params, headers=yelp_headers)
response

sf_data = response.json()
sf_data
sf_takeout_df = pd.DataFrame(sf_data['businesses'])
sf_takeout_df

sf_takeout_df.to_csv("sf_takeout.csv", index=False)<jupyter_output><empty_output><jupyter_text>Create SQLite file for San Francisco Take Outs<jupyter_code>connection = "sqlite:///sf_takeout.sqlite"
sf_df = pd.read_sql("sf_takeout", con=connection)
sf_df<jupyter_output><empty_output><jupyter_text>Take-Out & Delivery in Daly City, CA<jupyter_code>base_url = "https://api.yelp.com/v3/businesses/search"
yelp_headers = {
    "Authorization": "<KEY>"
}
yelp_params = {
    "term": "delivery",
    "location": "Daly City, CA", 
    "limit": 50,
    "radius": 20000
}
#Perform API Key request.
response = requests.get(base_url, params=yelp_params, headers=yelp_headers)
response
dc_data = response.json()
dc_data
dc_takeout_df = pd.DataFrame(dc_data['businesses'])
dc_takeout_df

dc_takeout_df.to_csv("dc_takeout.csv", index=False)<jupyter_output><empty_output><jupyter_text>Create SQLite for Daly City Take-Outs<jupyter_code>dc_takeout_df = dc_takeout_df.astype(str)
dc_takeout_df.to_sql("dc_takeout_7", con=dc_connection)
dc_df = pd.read_sql("dc_takeout_2", con=dc_connection)
dc_df
dc_connection = "sqlite:///dc_takeout.sqlite"<jupyter_output><empty_output><jupyter_text>Take Out and Delivery in San Bruno, CA<jupyter_code>base_url = "https://api.yelp.com/v3/businesses/search"
yelp_headers = {
    "Authorization": "<KEY>"
}
yelp_params = {
    "term": "delivery",
    "location": "San Bruno, CA", 
    "limit": 50,
    "radius": 20000
}
#Perform API Key request.
response = requests.get(base_url, params=yelp_params, headers=yelp_headers)
response
sbr_data = response.json()
sbr_data
sbr_takeout_df = pd.DataFrame(sbr_data['businesses'])
sbr_takeout_df
sbr_takeout_df.to_csv("sb_takeout.csv", index=False)<jupyter_output><empty_output><jupyter_text>Create SQLite for San Bruno Take-Outs<jupyter_code>sbr_takeout_df = sbr_takeout_df.astype(str)
sbr_takeout_df.to_sql("sbr_takeout_11", con=sbr_connection)
sbr_connection = "sqlite:///sbr_takeout.sqlite"<jupyter_output><empty_output><jupyter_text>Take Out & Delivery in South San Francisco<jupyter_code>base_url = "https://api.yelp.com/v3/businesses/search"
yelp_headers = {
    "Authorization": "Bearer <KEY>"
}
yelp_params = {
    "term": "delivery",
    "location": "South San Francisco, CA", 
    "limit": 50,
    "radius": 20000   
}
#Perform API Key request.
response = requests.get(base_url, params=yelp_params, headers=yelp_headers)
response
ssf_data = response.json()
ssf_data
ssf_takeout_df = pd.DataFrame(ssf_data['businesses'])
ssf_takeout_df
ssf_takeout_df.to_csv("sb_takeout.csv", index=False)<jupyter_output><empty_output><jupyter_text>Create SQLite File for South San Francisco Take-Outs<jupyter_code>ssf_takeout_df = ssf_takeout_df.astype(str)
ssf_takeout_df.to_sql("ssf_takeout_11", con=ssf_connection)
ssf_connection = "sqlite:///ssf_takeout.sqlite"<jupyter_output><empty_output><jupyter_text>Take Out & Delivery in Millbrae<jupyter_code>base_url = "https://api.yelp.com/v3/businesses/search"
yelp_headers = {
    "Authorization": "Bearer <KEY>"
}
yelp_params = {
    "term": "delivery",
    "location": "Millbrae, CA", 
    "limit": 50,
    "radius": 20000   
}
#Perform API Key request.
response = requests.get(base_url, params=yelp_params, headers=yelp_headers)
response
mlbr_data = response.json()
mlbr_data
mlbr_takeout_df = pd.DataFrame(mlbr_data['businesses'])
mlbr_takeout_df
mlbr_takeout_df.to_csv("mlbr_takeout.csv", index=False)<jupyter_output><empty_output><jupyter_text>Create SQLite File for Millbrae Take-Outs<jupyter_code>mlbr_takeout_df = mlbr_takeout_df.astype(str)
mlbr_takeout_df.to_sql("mlbr_takeout_2", con=mlbr_connection)
mlbr_connection = "sqlite:///mlbr_takeout.sqlite"<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.12407190308714341, 'fraction_numerical': 0.013481828839390387, 'mean_word_length': 7.256451612903226, 'pattern_counts': {'":': 25, '<': 55, '<?xml version=': 0, '>': 55, 'https://': 6, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '12', 'dir': 'jupyter-structured-clean-dedup', 'id': '604854', 'license': 'MIT', 'n_tokens_mistral': 2096, 'n_tokens_neox': 2006, 'n_words': 310, 'path': 'Yelp_Delivery/Yelp_API_Updated_Apr9.2020.ipynb', 'repo_name': 'veronica-morales/Yelp_Delivery', 'size': '5771'}