I have a large set of data received from DarkSky (the weather API), and I'd like to get the value of "summary"
.
It is meant to be in JSON format, that I have then translated into a dictionary. However, python is recognising the "data"
as a list, not a dictionary. How would I go about getting the value of "summary"
from this data?
darkSkyURL ="https://api.darksky.net/forecast/###Key has Been Removed###/{},{},{}?exclude=minutely,currently,flags,hourly".format(latitude, longitude, unixTime) #creates appropriate url, using known Long, Lang and current epoch time. These values are formatted into the url
darkSkyReport = requests.get(darkSkyURL)
darkSkyData = darkSkyReport.json()
print(darkSkyData["daily"]["data"]["summary"]))
Heres the parsed data:
{
'latitude': REMOVED,
'longitude': REMOVED,
'timezone': 'Europe/London',
'daily': {
'data': [{
'time': 1568156400,
'summary': 'Mostly cloudy throughout the day.',
'icon': 'rain',
'sunriseTime': 1568180039,
'sunsetTime': 1568226922,
'moonPhase': 0.43,
'precipIntensity': 0.0059,
'precipIntensityMax': 0.0392,
'precipIntensityMaxTime': 1568160000,
'precipProbability': 0.71,
'precipType': 'rain',
'temperatureHigh': 65.89,
'temperatureHighTime': 1568210400,
'temperatureLow': 53.98,
'temperatureLowTime': 1568268000,
'apparentTemperatureHigh': 65.89,
'apparentTemperatureHighTime': 1568210400,
'apparentTemperatureLow': 53.98,
'apparentTemperatureLowTime': 1568268000,
'dewPoint': 50.7,
'humidity': 0.72,
'pressure': 1016.26,
'windSpeed': 14.02,
'windGust': 36.33,
'windGustTime': 1568206800,
'windBearing': 254,
'cloudCover': 0.54,
'uvIndex': 4,
'uvIndexTime': 1568203200,
'visibility': 6.776,
'ozone': 272.7,
'temperatureMin': 53.14,
'temperatureMinTime': 1568160000,
'temperatureMax': 65.89,
'temperatureMaxTime': 1568210400,
'apparentTemperatureMin': 53.14,
'apparentTemperatureMinTime': 1568160000,
'apparentTemperatureMax': 65.89,
'apparentTemperatureMaxTime': 1568210400
}]
},
'offset': 1
}
index in the array of data then load summary object
darkSkyURL ="https://api.darksky.net/forecast/###Key has Been Removed###/{},{},{}?exclude=minutely,currently,flags,hourly".format(latitude, longitude, unixTime) #creates appropriate url, using known Long, Lang and current epoch time. These values are formatted into the url
darkSkyReport = requests.get(darkSkyURL)
darkSkyData = darkSkyReport.json()
summary = darkSkyData["daily"]["data"][0]["summary"]