| tbl_csv | R Documentation |
Opens a delimited text file (CSV, TSV, or any single-character separator)
for lazy, streaming query execution. Column types are inferred from the
first 1000 rows. No data is read until collect() is called.
Gzip-compressed files (.csv.gz, .tsv.gz) are supported transparently.
tbl_csv(path, batch_size = .DEFAULT_BATCH_SIZE, delim = ",")
path |
Path to a delimited text file, optionally gzip-compressed. |
batch_size |
Number of rows per batch (default 65536). |
delim |
Single-character field separator (default |
The field separator is set by delim, so tab-separated files (GBIF
occurrence exports, TSV dumps) and semicolon-separated files (many European
exports) are read natively without a transcode step. Quoting follows RFC
4180 for every delimiter: a field wrapped in double quotes may contain the
delimiter, newlines, and doubled quotes.
A vectra_node object representing a lazy scan of the file.
f <- tempfile(fileext = ".csv")
write.csv(mtcars, f, row.names = FALSE)
node <- tbl_csv(f)
print(node)
unlink(f)
# Tab-separated (e.g. a GBIF occurrence export)
g <- tempfile(fileext = ".tsv")
write.table(mtcars, g, sep = "\t", row.names = FALSE, quote = FALSE)
tbl_csv(g, delim = "\t") |> collect() |> head()
unlink(g)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.