Skip to contents

Reads every file under path with an established reader and returns one row per column of each table and per block of running text. Nothing is skipped silently: pii_read_report() lists every file as read, unsupported or failed, with the reason.

Usage

pii_read(path, ignore = character(), root = ".")

Arguments

path

Files or directories. Directories are searched recursively.

ignore

Globs of files not to read. They are reported as ignored.

root

The folder ignore globs are relative to, normally the one holding .piinata.yml.

Value

A tibble of fields; see as_pii_fields().

Details

Delimited text, Excel, Stata, SPSS and SAS files, R data, and plain text are always readable. Parquet, JSON, PDF, Word, RTF, HTML and Qualtrics exports need a suggested package and are reported as unsupported, naming the package, when it is missing. Variable labels and Qualtrics question text are kept as the field's label.

Examples

file <- tempfile(fileext = ".csv")
write.csv(data.frame(q1 = c("a@example.org", "b@example.org")), file, row.names = FALSE)
fields <- pii_read(file)
fields
#> # A tibble: 1 × 7
#>   source                               locator name  label values    kind  type 
#>   <chr>                                <chr>   <chr> <chr> <list>    <chr> <chr>
#> 1 /tmp/RtmpeoiXV6/file1d793a468db3.csv q1      q1    NA    <chr [2]> tabu… char…
pii_read_report(fields)
#> # A tibble: 1 × 4
#>   source                               status n_fields detail
#>   <chr>                                <chr>     <int> <chr> 
#> 1 /tmp/RtmpeoiXV6/file1d793a468db3.csv read          1 NA