Weather API connect


In [60]:
import urllib.request
import pandas as pd
import numpy as np
import requests
from urllib.request import Request, urlopen
from pandas.io.json import json_normalize


loc = "London,uk"
weatherurl ='http://api.openweathermap.org/data/2.5/weather?q=' + loc + '?id=524901&APPID=b058d678cdbcdfdadaa17156d4a9a5fd'
data= requests.get(weatherurl)
#data.text
dataj=data.json()
temp=dataj['main']['temp_max']-273.15

objects = (loc, 'Max')
y_pos = np.arange(len(objects))
performance = [temp, 1]
 
plt.bar(y_pos, performance, align='center', alpha=0.5)
plt.xticks(y_pos, objects)
plt.ylabel('t')
plt.title('Temp in '+loc)
 
plt.show()



In [ ]:
# For the future more sophisiticated transformations - to DataFrame
#import json
# Finish request http://pandas.pydata.org/pandas-docs/stable/generated/pandas.read_json.html

#pd.read_json(data.json(),orient='records', typ="series" )

Write diary to spreadsheet

via google API

  1. Define date (default=today)
  2. Define topic oAuth
  3. Append via API https://developers.google.com/sheets/api/reference/rest/v4/spreadsheets.values/append