Jython scripters often need to get a list of records inside a DSS file. This type of operation can be done with the HecDssCatalog class.
See the java docs for all details:
https://www.hec.usace.army.mil/software/javadocs/hec-monolith/hec/heclib/dss/HecDssCatalog.html
The example script below shows getting raw catalog, condensed catalog, and filtered condensed catalog.
# Jython examples to get pathnames from a DSS file.
from hec.heclib.dss import HecDssCatalog
catalog = HecDssCatalog("c:/tmp/sample7.dss")
sorted = True
paths = catalog.getCatalog(sorted) # get sorted catalog all records (NOT condensed)
for p in paths:
print(p)
# example output:
# /MY BASIN/RIVERSIDE/PRECIP-INC/01Mar1990/1Hour/OBS/
# /MY BASIN/RIVERSIDE/PRECIP-INC/01Apr1990/1Hour/OBS/
# /MY BASIN/RIVERSIDE/PRECIP-INC/01May1990/1Hour/OBS/
paths = catalog.getCondensedCatalog(None) # get all paths in condensed format
for p in paths:
print(p)
# example output
# -------------------------
# /MY BASIN/DEER CREEK/STAGE-FLOW///USGS/
# /MY BASIN/RIVERSIDE/FLOW/01Mar1990 - 31May1990/1Hour/OBS/
# /MY BASIN/RIVERSIDE/PRECIP-INC/01Mar1990 - 31May1990/1Hour/OBS/
# /MY BASIN/RIVERSIDE/STAGE/01Mar1990 - 31May1990/1Hour/OBS/
# /MY BASIN/RIVERSIDE/TEMP-AIR/01Mar1990 - 31May1990/1Hour/OBS/
# /NE ANACOSTIA/RIVERDALE/FREQ-FLOW/MAX ANALYTICAL//1969-01 H33(MAX)/
print("[-------------]")
paths = catalog.getCondensedCatalog("/*/*/Flow*/*/*/*/") # get all paths in condensed format that have a C part starting with Flow
for p in paths:
print(p)
# example output
# -------------------------
# /MISSISSIPPI/ST. LOUIS/FLOW/01Jan1890 - 31Dec1890/1Day/OBS/
# /GREEN RIVER/GLENFIR/FLOW/01Jan1938 - 31Dec1938/1Hour/OBS/
# /GREEN RIVER/WALNUT/FLOW-RES OUT/01Jan1979 - 31Dec1979/1Hour/OBS/
# /MISSISSIPPI/ST. LOUIS/FLOW/01Jan1998 - 31Dec2006/1Day/OBS/
PYTHON