catch switched start/end dates
Closed this issue · 0 comments
veenstrajelmer commented
- ddlpy version: main
- Python version: 3.11
- Operating System: Windows
Description
When accidentally requesting data with start/end date switched, DDL gives "NoDataException: Check meetwaarden aanwezig mislukt"
. ddlpy.measurements()
gives no error at all because the month loop is empty, although ddl does give a decent error. Consider catching this with ddlpy or let ddl provide better feedback.
What I Did
import ddlpy
locations = ddlpy.locations()
bool_hoedanigheid = locations['Hoedanigheid.Code'].isin(['NAP'])
bool_stations = locations.index.isin(['HOEKVHLD'])
bool_grootheid = locations['Grootheid.Code'].isin(['WATHTE'])
# bool_groepering = locations['Groepering.Code'].isin(['NVT'])
selected = locations.loc[bool_grootheid & bool_hoedanigheid & bool_stations]
start_date = "2019-02-01"
end_date = "2019-01-01"
# if we pass one row to the measurements function you can get all the measurements
avail = ddlpy.measurements_available(selected.iloc[0], start_date, end_date)
measurements = ddlpy.measurements(selected.iloc[0], start_date, end_date)