Apr-22-2020, 08:09 AM
Hey All, Trying to get the below script to allow a user to input a storeID number; which then looks up the coordinates and inputs them into the variables. Can anyone help please? :)
import requests import pandas as pd df = pd.read_excel ('C:\Sites.xlsx') print ("Please Enter the SiteID/No.:") user = input("") print (df.loc[df['SiteId'] == user]): latitude = (df.loc[df['SiteLatitude']) longitude = (df.loc[df['SiteLongitude']) url = 'http://api.openweathermap.org/data/2.5/weather?lat={}&lon={}&appid=0c42f7f6b53b244c78a418f4f181282a&q&units=metric'.format(latitude, longitude) res = requests.get(url) data = res.json() temp = data['main']['temp'] wind_speed = data['wind']['speed'] description = data['weather'][0]['description'] destination = data['name'] print('\nDestination : {}'.format(destination)) print('Temperature : {} Degree Celcius'.format(temp)) print('Wind Speed : {} m/s'.format(wind_speed)) print('Description : {}'.format(description))EXCEL Sheet eg.
Output:SiteId SiteName SiteClosedFlag SiteLatitude SiteLongitude
1 Sheffield Closed 53.3811 1.4701
2 Nottingham Open 52.9548 1.1581
3 Leeds Open 53.8008 1.5491
4 Wales Open 52.1307 3.7837