| btread | R Documentation |
A from-scratch delimited-file reader written in C++: the file is memory mapped, scanned once for row boundaries (RFC 4180 quoting), type-guessed from a bounded sample, and materialised into typed vectors. Numeric columns are filled by a thread pool; character columns are built on the R thread.
btread(
file,
delim = NULL,
header = TRUE,
col_names = NULL,
col_types = NULL,
col_select = NULL,
na = c("NA", ""),
quote = "\"",
comment = "",
trim_ws = FALSE,
skip = 0,
n_max = Inf,
guess_max = 10000,
lazy = FALSE,
n_threads = bt_default_threads(),
as = c("data.frame", "basetable")
)
file |
Path to a delimited text file. |
delim |
Field delimiter. |
header |
Logical; does the first row hold column names? |
col_names |
Optional character vector of names, used only when
|
col_types |
|
col_select |
Optional integer positions or character names of the columns to keep. Other columns are not parsed. |
na |
Character vector of strings to read as |
quote |
Quoting character. |
comment |
Lines beginning with this one-character string are skipped
( |
trim_ws |
Logical; strip leading/trailing spaces and tabs from unquoted fields. |
skip |
Number of raw lines to discard before reading. |
n_max |
Maximum number of data rows to read ( |
guess_max |
Number of rows sampled for type guessing. |
lazy |
Logical; return numeric columns as lazily-parsed ALTREP vectors. |
n_threads |
Number of worker threads for the eager numeric fill. |
as |
Return |
With lazy = TRUE the integer and double columns are returned as ALTREP
vectors that parse their column only the first time it is touched, which
makes "read a few columns from a wide file" close to free.
A data.frame.
p <- tempfile(fileext = ".csv")
write.csv(head(iris), p, row.names = FALSE)
btread(p)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.