-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Description
Thinking of the use case of using list_sas_files() in convert_register(), this currently would require a folder with only files from one register. Since files from multiple registers are usually in the same folder, e.g., Grunddata/, it might make sense to add some kind of filter paramenter to list_sas_files(), something like:
list_sas_files <- function(path, filter = NULL) { # added filter here
# Check input.
checkmate::assert_directory(path)
checkmate::assert_string(path)
checkmate::assert_string(filter, null.ok = TRUE) # added
# List all SAS files in the directory and its subdirectories.
# (?i) makes the regex case-insensitive.
filter_pattern <- if (is.null(filter)) "" else filter # added
sas_files <- fs::dir_ls(
path,
regexp = glue::glue("(?i){filter_pattern}[^/]*\\.sas7bdat$"), # glue and `{filter_pattern}[^/]*` added
recurse = TRUE
) |>
sort()
if (length(sas_files) == 0) {
cli::cli_abort("No SAS files found in {.path {path}}.")
}
sas_files
}
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels
Type
Projects
Status
In review