Skip to content

Create better error handling with nwis.get_stats #171

Description

@ehinman

Recently ran into an error when running the following code for site 02469675 (it isn't currently maintained):

import dataretrieval
test = dataretrieval.nwis.get_stats(sites='02469675')

.....
fields = re.split('[\t]', rdb.splitlines()[count]) # points to this as being the issue
fields = [field.replace(',', '') for field in fields]
dtypes = {
'site_no': str,
 'dec_long_va': float,
   (...)
'parameter_cd': str,
}

IndexError: list index out of range

This is because the link (https://waterservices.usgs.gov/nwis/stat/?sites=02469675) returns the following:

# //Output-Format: RDB
# //Response-Status: OK
# //Response-Message: No sites found matching all criteria

I think we should accommodate these potential responses.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions