archive_read: Create a readable connection to a file in an archive.

View source: R/archive_read.R

archive_readR Documentation

Create a readable connection to a file in an archive.

Description

Create a readable connection to a file in an archive.

Usage

archive_read(
  archive,
  file = 1L,
  mode = "r",
  format = NULL,
  filter = NULL,
  options = character()
)

Arguments

archive

character(1) The archive filename or an archive object.

file

character(1) || integer(1) The filename within the archive, specified either by filename or by position.

mode

character(1) A description of how to open the connection (if it should be opened initially). See section ‘Modes’ in base::connections() for possible values.

format

character(1) default: NULL The archive format, one of \evalchoices_rd(names(archive:::archive_formats())). Supported formats differ depending on the libarchive version and build.

filter

character(1) default: NULL The archive filter, one of \evalchoices_rd(names(archive:::archive_filters())). Supported filters differ depending on the libarchive version and build.

options

character() default: character(0) Options to pass to the filter or format. The list of available options are documented in options can have one of the following forms:

  • option=value The option/value pair will be provided to every module. Modules that do not accept an option with this name will ignore it.

  • option The option will be provided to every module with a value of "1".

  • !option The option will be provided to every module with a NULL value.

  • module:option=value, module:option, module:!option As above, but the corresponding option and value will be provided only to modules whose name matches module. See read options for available read options See write options for available write options

Value

An 'archive_read' connection to the file within the archive to be read.

Examples

a <- system.file(package = "archive", "extdata", "data.zip")
# Show files in archive
a

# By default reads the first file in the archive.
read.csv(archive_read(a), nrows = 3)

# Can also specify a filename directly
read.csv(archive_read(a, "mtcars.csv"), nrows = 3)

# Or by position
read.csv(archive_read(a, 3), nrows = 3)

# Explicitly specify the format and filter if automatic detection fails.
read.csv(archive_read(a, format = "zip"), nrows = 3)

archive documentation built on Sept. 13, 2024, 1:07 a.m.