Skip to content

Commit af96059

Browse files
committed
Add try/except statement to dataretrieval query
1 parent 696580d commit af96059

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

notebooks/part1_flopy/04_Modelgrid_and_intersection.ipynb

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1270,9 +1270,11 @@
12701270
"outputs": [],
12711271
"source": [
12721272
"import dataretrieval.nwis as nwis\n",
1273-
"\n",
1274-
"gage = nwis.get_record(sites=station_id, service='iv', start=\"2024-01-01\", end=\"2024-12-31\", parameterCd=\"00065\")\n",
1275-
"gage.to_csv(data_path / \"sagehen_gage_data.csv\")"
1273+
"try:\n",
1274+
" gage = nwis.get_record(sites=station_id, service='iv', start=\"2024-01-01\", end=\"2024-12-31\", parameterCd=\"00065\")\n",
1275+
" gage.to_csv(data_path / \"sagehen_gage_data.csv\")\n",
1276+
"except (ValueError, ConnectionError, NameError):\n",
1277+
" gage = pd.read_csv(data_path / \"sagehen_gage_data.csv\")"
12761278
]
12771279
},
12781280
{
@@ -1282,7 +1284,6 @@
12821284
"metadata": {},
12831285
"outputs": [],
12841286
"source": [
1285-
"gage = pd.read_csv(data_path / \"sagehen_gage_data.csv\")\n",
12861287
"gage[\"datetime\"] = pd.to_datetime(gage[\"datetime\"])\n",
12871288
"gage = gage.set_index(\"datetime\")\n",
12881289
"\n",

0 commit comments

Comments
 (0)