Skip to contents

Test helper: reads the single parquet file in odir whose basename (from lf) matches pattern. Errors on zero or multiple matches unless first = TRUE.

Usage

read_parquet_grep(odir, lf, pattern, first = FALSE)

Arguments

odir

(character(1))
Directory the files live in.

lf

(character(n))
Basenames to match pattern against.

pattern

(character(1))
Regex passed to grep().

first

(logical(1))
If pattern matches more than one file, read the first match instead of erroring.

Value

(tibble) Parsed parquet file.

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