pb_read: Read one file into memory

View source: R/pb_read.R

pb_readR Documentation

Read one file into memory

Description

A convenience wrapper around writing an object to a temporary file and then uploading to a specified repo/release. This convenience comes at a cost to performance efficiency, since it first downloads the data to disk and then reads the data from disk into memory. See vignette("cloud_native") for alternative ways to bypass this flow and work with the data directly.

Usage

pb_read(
  file,
  ...,
  repo = guess_repo(),
  tag = "latest",
  read_function = guess_read_function(file),
  .token = gh::gh_token()
)

Arguments

file

string: file name

...

additional arguments passed to read_function after file

repo

string: GH repository name in format "owner/repo". Default guess_repo() tries to guess based on current working directory's git repo

tag

string: tag for the GH release, defaults to "latest"

read_function

function: used to read in the data, where the file is passed as the first argument and any additional arguments are subsequently passed in via .... Default guess_read_function(file) will check the file extension and try to find an appropriate read function if the extension is one of rds, csv, tsv, parquet, txt, or json, and will abort if not found.

.token

GitHub authentication token, see gh::gh_token()

Value

Result of reading in the file in question.

See Also

Other pb_rw: guess_read_function(), guess_write_function(), pb_write()

Examples


try({ # try block is to avoid CRAN issues and is not required in ordinary usage
 piggyback::pb_read("mtcars.tsv.gz", repo = "cboettig/piggyback-tests")
})


cboettig/piggyback documentation built on Feb. 29, 2024, 2:35 a.m.