Skip to content

Checking availability of flow and/or level data before downloading #166

Answered by boshek
rchlumsk asked this question in Q&A
Discussion options

You must be logged in to vote

Definitely deleted the wrong one. Not a naive question at all. Great idea. I think the best approach would be to query the data a la:

library(tidyhydat)
library(dbplyr)
library(dplyr)


hy_check_for_data <- function(station_number, hydat_table) {
  hydat_con <- hy_src()

  tbl(hydat_con, hydat_table) %>%
    filter(STATION_NUMBER %in% station_number) %>%
    group_by(STATION_NUMBER) %>%
    summarise(
      nrows = n(),
      min_year = min(YEAR, na.rm = FALSE),
      max_year = max(YEAR, na.rm = FALSE)
    )
}

hy_check_for_data(c("08MF005", "fffff"), "DLY_FLOWS")
#> # Source:   lazy query [?? x 4]
#> # Database: sqlite 3.36.0
#> #   [C:\Users\salbers\AppData\Local\tidyhydat\tidyhydat\Hy…

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@rchlumsk
Comment options

@boshek
Comment options

Answer selected by rchlumsk
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants