-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinspect_data.py
More file actions
23 lines (20 loc) · 955 Bytes
/
inspect_data.py
File metadata and controls
23 lines (20 loc) · 955 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
from data_fetcher import fetch_streamflow_data
import json
try:
data = fetch_streamflow_data('TN')
# Print keys of the top level object
print("Top level keys:", data.keys())
# It seems to be a USGS NWIS response. Usually it has 'value' -> 'timeSeries'
if 'value' in data and 'timeSeries' in data['value']:
time_series = data['value']['timeSeries']
print(f"Number of sites found: {len(time_series)}")
if len(time_series) > 0:
first_site = time_series[0]
# Print structure of the first site to find name and site code
print("First site structure keys:", first_site.keys())
print("SourceInfo:", json.dumps(first_site.get('sourceInfo'), indent=2))
print("Variable:", json.dumps(first_site.get('variable'), indent=2))
else:
print("Unexpected structure:", json.dumps(data, indent=2)[:500])
except Exception as e:
print(f"Error: {e}")