Skip to content

Commit a6ee363

Browse files
committed
support parqet extensions on nssp local file
1 parent d0bfb69 commit a6ee363

File tree

1 file changed

+21
-8
lines changed

1 file changed

+21
-8
lines changed

R/update_hub_target_data.R

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -95,15 +95,28 @@ update_hub_target_data <- function(
9595
}
9696

9797
if (nssp_update_local) {
98-
raw_nssp_data <- forecasttools::read_tabular(
99-
fs::path(
100-
base_hub_path,
101-
"auxiliary-data",
102-
"nssp-raw-data",
103-
"latest",
104-
ext = "csv"
98+
nssp_dir <- fs::path(
99+
base_hub_path,
100+
"auxiliary-data",
101+
"nssp-raw-data"
102+
)
103+
# find latest.* file (csv or parquet)
104+
nssp_files <- fs::dir_ls(nssp_dir, regexp = "latest\\.(csv|parquet)$")
105+
106+
if (length(nssp_files) == 0) {
107+
cli::cli_abort(
108+
glue::glue(
109+
"Cannot find NSSP data file (latest.csv or latest.parquet) ",
110+
"in {nssp_dir}."
111+
)
105112
)
106-
) |>
113+
}
114+
115+
nssp_file_path <- nssp_files[which.max(
116+
fs::path_ext(nssp_files) == "parquet"
117+
)]
118+
119+
raw_nssp_data <- forecasttools::read_tabular(nssp_file_path) |>
107120
dplyr::filter(.data$county == "All") |>
108121
dplyr::select(
109122
"week_end",

0 commit comments

Comments
 (0)