-
Notifications
You must be signed in to change notification settings - Fork 0
/
SMHIData.py
43 lines (35 loc) · 1.41 KB
/
SMHIData.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import json, requests, pprint
#def getRain(timeString):
# url = 'http://opendata-download-metfcst.smhi.se/api/category/pmp1.5g/version/1/geopoint/lat/58.41/lon/15.63/data.json'
# resp = requests.get(url=url)
# data = json.loads(resp.text)
# dataResult =data['timeseries']
# string = str('2015-09-05T'+timeString+'Z')
# pp = pprint.PrettyPrinter(indent=4)
# for fields in dataResult:
# if(fields['validTime']==string):
# pp.pprint("Det kommer att regna "+str(fields['pit'])+ " mm/h vid klockan "+str(timeString))
#def getTempature(timeString):
# url = 'http://opendata-download-metfcst.smhi.se/api/category/pmp1.5g/version/1/geopoint/lat/58.41/lon/15.63/data.json'
# resp = requests.get(url=url)
# data = json.loads(resp.text)
# dataResult =data['timeseries']
# string = str('2015-09-05T'+timeString+'Z')
# pp = pprint.PrettyPrinter(indent=4)
# for fields in dataResult:
# if(fields['validTime']==string):
# return fields['t']
def getSMHIdata(timeString):
url = 'http://opendata-download-metfcst.smhi.se/api/category/pmp1.5g/version/1/geopoint/lat/58.41/lon/15.63/data.json'
resp = requests.get(url=url)
data = json.loads(resp.text)
dataResult =data['timeseries']
string = str('2015-09-06T'+timeString+'Z')
pp = pprint.PrettyPrinter(indent=4)
for fields in dataResult:
if(fields['validTime']==string):
return fields
#string = '17:00:00'
#readDataRain(string)
#readDataTempature(string)
#print(getSMHIdata(string))