Hi
I'm new to Glom an Python so this may be a rookie mistake. I'm trying to print a value from tier 3 of this dictionary which is created from an API.
I can read values from keys in the 2nd level but not the third. I feel like I'm doing it right from reading the documents but I'm not getting the result I need.
Any input would be much appreciated.
I have listed the code below.
import json
import requests
import time
from bs4 import BeautifulSoup
from nested_lookup import nested_lookup
from glom import glom as glom
from glom import Coalesce
from glom import glom, Path
from glom import glom, Inspect
import pprint
Hi I'm new to Glom an Python so this may be a rookie mistake. I'm trying to print a value from tier 3 of this dictionary which is created from an API.
I can read values from keys in the 2nd level but not the third. I feel like I'm doing it right from reading the documents but I'm not getting the result I need.
Any input would be much appreciated.
I have listed the code below.
import json import requests import time from bs4 import BeautifulSoup from nested_lookup import nested_lookup from glom import glom as glom from glom import Coalesce from glom import glom, Path from glom import glom, Inspect import pprint
baseURL = "http://environment.data.gov.uk/flood-monitoring/id/stations/" stationId = "F1806"
test for connection
response = requests.get(baseURL + stationId) print() print("=======================") print("Server Status - " + str(response.status_code)) print() print("Read JSON Data") print() parsed_json = (response.json()) print(json.dumps(parsed_json, indent=4, sort_keys=True)) print("=======================")
print()
Create Glomspec
print(glom(parsed_json, ('items.measures',['label']))) print() print(glom(parsed_json, Path('items.measures.latestReading',['value'])))