tbl_csv: Create a lazy table reference from a delimited text file

View source: R/tbl.R

tbl_csvR Documentation

Create a lazy table reference from a delimited text file

Description

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.

Usage

tbl_csv(path, batch_size = .DEFAULT_BATCH_SIZE, delim = ",")

Arguments

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 ","). Use "\t" for tab-separated and ";" for semicolon-separated files.

Details

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.

Value

A vectra_node object representing a lazy scan of the file.

Examples

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)


vectra documentation built on July 10, 2026, 5:08 p.m.