Test helper: reads the single parquet file in odir whose basename (from
lf) matches pattern. Errors on zero or multiple matches unless
first = TRUE.
Arguments
- odir
(
character(1))
Directory the files live in.- lf
(
character(n))
Basenames to matchpatternagainst.- pattern
(
character(1))
Regex passed togrep().- first
(
logical(1))
Ifpatternmatches more than one file, read the first match instead of erroring.
Examples
odir <- fs::dir_create(tempfile())
arrow::write_parquet(data.frame(x = 1L), file.path(odir, "a_1.parquet"))
arrow::write_parquet(data.frame(x = 2L), file.path(odir, "a_2.parquet"))
lf <- list.files(odir)
(x <- read_parquet_grep(odir, lf, "a_1"))
#> # A tibble: 1 × 1
#> x
#> <int>
#> 1 1
(y <- read_parquet_grep(odir, lf, "^a_", first = TRUE))
#> # A tibble: 1 × 1
#> x
#> <int>
#> 1 1
