#CrossCompute
target_folder = '/tmp'
# load table
import pandas as pd
t = pd.read_csv('Interactive_Map_Data.csv', encoding='latin-1', skiprows=1)
#get address
address = '1472 Broadway, New York, NY 10036'
user_number = "+17188380942"
#convert address to latitude and longtitude
from geopy.geocoders import Nominatim
geolocator = Nominatim()
location = geolocator.geocode(address)
lat = location.latitude
long = location.longitude
#find to cloesest latitude and longtitude
lat_table = t.loc[abs(t['LATITUDE']-lat)< 0.01]
long_table = t.loc[abs(t['LONGITUDE']-long) < 0.01]
find_table = pd.merge(lat_table,long_table)
def f(c):
return abs(c['LATITUDE']-lat) + abs(c['LONGITUDE']-long)
find_table['sum'] = find_table.apply(f, axis = 1)
find_table.sort_values(['sum'],ascending=True)
find_table.head(6)
message_body = "<< " + find_table.head(6)['Film']+ " >>" +" address is " +find_table.head(6)['Location Display Text']
string = message_body.any().replace('<br>','')
#load map
#mark addresses on the map
target_path = target_folder + '/map.csv'
find_table.head(6).to_csv(target_path, index=False)
print('asdf_geotable_path = %s' % target_path)
# Download the Python helper library from twilio.com/docs/python/install
from twilio.rest import Client
# use twilio api to send user message
account_sid = "ACa2c9ff9c45d3bb4e4dd836e6d5ede729"
auth_token = "ff8ac3c95c12cfd287f1621a6afa90a2"
client = Client(account_sid, auth_token)
message = client.messages.create(
body="Hey bro",
to=user_number,
from_="+13478538680")
print(message.sid)