Title: | Read and Write Column Text Format (CTF) |
---|---|
Description: | Column Text Format (CTF) is a new tabular data format designed for simplicity and performance. CTF is the simplest column store you can imagine: plain text files for each column in a table, and a metadata file. The underlying plain text means the data is human readable and familiar to programmers, unlike specialized binary formats. CTF is faster than row oriented formats like CSV when loading a subset of the columns in a table. This package provides functions to read and write CTF data from R. |
Authors: | Clark Fitzgerald [aut, cre]
|
Maintainer: | Clark Fitzgerald <[email protected]> |
License: | MIT + file LICENSE |
Version: | 0.1.0 |
Built: | 2025-02-13 05:13:26 UTC |
Source: | https://github.com/cran/ctf |
Read external CTF data into the corresponding R data frame.
read.ctf(location, columns, nrows)
read.ctf(location, columns, nrows)
location |
location of the CTF data, either a file path to a CTF metadata JSON file, or a directory containing a single CTF metadata JSON file. |
columns |
names of the columns to read. If missing, then read in all columns. |
nrows |
integer, the maximum number of rows to read in. If missing, then read in all rows. |
data frame
write.ctf
to write CTF
# An example CTF metadata file included in this package d <- system.file("extdata", "vgsales", "vgsales-metadata.json", package = "ctf") # Read all the rows and columns vgsales <- read.ctf(d) # Read 10 rows of two columns, Name and Rank vgsales2 <- read.ctf(d, columns = c("Name", "Rank"), nrows = 10)
# An example CTF metadata file included in this package d <- system.file("extdata", "vgsales", "vgsales-metadata.json", package = "ctf") # Read all the rows and columns vgsales <- read.ctf(d) # Read 10 rows of two columns, Name and Rank vgsales2 <- read.ctf(d, columns = c("Name", "Rank"), nrows = 10)
Save a data frame using Column Text Format
write.ctf(x, datadir = name, name = deparse(substitute(x)), ...)
write.ctf(x, datadir = name, name = deparse(substitute(x)), ...)
x |
data frame to write |
datadir |
directory to write the metadata and CTF columns |
name |
table name |
... |
further arguments to |
NULL
, used for its side effect
read.ctf
to read CTF, write.table.raw
for the underlying functionality, and save
for writing any R objects.
d <- file.path(tempdir(), "iris_ctf_data") write.ctf(iris, d) # Same object as iris, but carries around some extra metadata iris2 <- read.ctf(d) # This directory contains plain text files for each column in iris list.files(d) # Clean up unlink(d, recursive = TRUE)
d <- file.path(tempdir(), "iris_ctf_data") write.ctf(iris, d) # Same object as iris, but carries around some extra metadata iris2 <- read.ctf(d) # This directory contains plain text files for each column in iris list.files(d) # Clean up unlink(d, recursive = TRUE)