cozip

R bindings for libcozip. Read a Cloud-Optimized ZIP archive's manifest over HTTP range requests, or write one from an arrow Table.

libzip, zlib and karu are vendored under src/. Building the reader needs a C++23 compiler, pkg-config, libcurl 7.83 or newer and OpenSSL 3. On Debian and Ubuntu, install libcurl4-openssl-dev and libssl-dev.

Install

install.packages("cozip", repos = "https://asterisk-labs.r-universe.dev")

Usage

Write

library(cozip)
library(arrow)

tbl <- arrow_table(
  name = c("a.txt", "b.bin"),
  path = c("/path/to/a.txt", "/path/to/b.bin")
)

create("out.zip", tbl)

name is how each file appears inside the archive. path is where it lives on disk, used at write time and dropped from the manifest. Any extra columns ride along into __metadata__ and become queryable on read.

Archive names must be ASCII. Writer source and output paths may contain Unicode; paths and URLs passed to cozip::read() are currently ASCII-only. Empty files are not valid cozip entries.

tbl <- arrow_table(
  name      = c("a.tif", "b.tif"),
  path      = c("/path/to/a.tif", "/path/to/b.tif"),
  cloud_pct = c(12.3, 45.1)
)

create("out.zip", tbl)

Read

library(cozip)

manifest <- read("https://example.com/dataset.zip")
train <- manifest[manifest$split == "train", ]

manifest is a tibble: name, offset, size, cozip:location, and the writer's extras. Local path or URL, same call. It fetches the byte-0 index and __metadata__, never the payloads.

columns = c(...) picks extras. location = FALSE drops cozip:location.

cozip::read() supports only Flat-profile archives (profile = 1). TACO archives (profile = 2) and all other profiles are rejected.

read() fetches the manifest through libcozip; DuckDB decodes Parquet without loading extensions. Remote reads use environment or standard credential files. For SQL over stored files, use the optional cozip_reader extension.

Versioning

The R package version tracks the C library exactly and is copied from the repo-root VERSION file by make sync.

packageVersion("cozip")  # "2026.9.4"

Spec

See SPEC.md for the on-disk format.

License

MIT. See LICENSE.