Skip to contents

Checks if the TSV file contains any non-header rows.

Usage

tsv_is_empty(
  x,
  comment = "##",
  col_types = readr::cols(.default = "c"),
  n_max = 1,
  ...
)

Arguments

x

Path to TSV file.

comment

Taken from readr::read_tsv().

col_types

Taken from readr::read_tsv().

n_max

Taken from readr::read_tsv().

...

Other arguments to be passed to readr::read_tsv().

Value

TRUE if there is at least one non-header row in the TSV, FALSE otherwise.

Examples


tmp1 <- tempfile()
writeLines(c("col1\tcol2\tcol3", "1\t2\t3"), con = tmp1)
(a <- tsv_is_empty(tmp1))
#> [1] FALSE

tmp2 <- tempfile()
writeLines(c("col1\tcol2\tcol3"), con = tmp2)
(b <- tsv_is_empty(tmp2))
#> /tmp/Rtmp9SHz04/file176260ecce0c does not contain any non-header rows.
#> [1] TRUE

tmp3 <- tempfile()
writeLines(c("##meta1", "##meta2", "col1\tcol2\tcol3"), con = tmp3)
(c <- tsv_is_empty(tmp3))
#> /tmp/Rtmp9SHz04/file176279eab7e3 does not contain any non-header rows.
#> [1] TRUE