{"id":13398676,"url":"https://github.com/r-lib/archive","last_synced_at":"2025-05-16T01:06:44.906Z","repository":{"id":42064364,"uuid":"84235239","full_name":"r-lib/archive","owner":"r-lib","description":"R bindings to libarchive, supporting a large variety of archive formats","archived":false,"fork":false,"pushed_at":"2025-03-24T16:07:19.000Z","size":6915,"stargazers_count":144,"open_issues_count":18,"forks_count":18,"subscribers_count":5,"default_branch":"main","last_synced_at":"2025-05-13T01:15:53.519Z","etag":null,"topics":["compression","connections","libarchive","r"],"latest_commit_sha":null,"homepage":"https://archive.r-lib.org/","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/r-lib.png","metadata":{"files":{"readme":"README.Rmd","changelog":"NEWS.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2017-03-07T18:59:55.000Z","updated_at":"2025-03-24T16:05:30.000Z","dependencies_parsed_at":"2024-06-18T20:03:00.680Z","dependency_job_id":"152512b6-edfe-40b0-b390-f6c6b3059488","html_url":"https://github.com/r-lib/archive","commit_stats":{"total_commits":324,"total_committers":9,"mean_commits":36.0,"dds":"0.13888888888888884","last_synced_commit":"014dd7aaa586f5bf4c38eae14b0e784ba1e52932"},"previous_names":["jimhester/archive"],"tags_count":14,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/r-lib%2Farchive","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/r-lib%2Farchive/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/r-lib%2Farchive/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/r-lib%2Farchive/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/r-lib","download_url":"https://codeload.github.com/r-lib/archive/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254448579,"owners_count":22072764,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["compression","connections","libarchive","r"],"created_at":"2024-07-30T19:00:30.431Z","updated_at":"2025-05-16T01:06:39.862Z","avatar_url":"https://github.com/r-lib.png","language":"C++","funding_links":[],"categories":["C++"],"sub_categories":[],"readme":"---\noutput: github_document\n---\n\n\u003c!-- README.md is generated from README.Rmd. Please edit that file --\u003e\n\n```{r, echo = FALSE}\nknitr::opts_chunk$set(\n  collapse = TRUE,\n  comment = \"#\u003e\",\n  fig.path = \"README-\"\n)\ndir \u003c- tempfile()\ndir.create(dir)\nknitr::opts_knit$set(root.dir = dir)\noptions(tibble.print_min = 4L)\nlibrary(archive)\n```\n# archive\n\n\u003c!-- badges: start --\u003e\n[![R-CMD-check](https://github.com/r-lib/archive/workflows/R-CMD-check/badge.svg)](https://github.com/r-lib/archive/actions)\n[![Coverage Status](https://img.shields.io/codecov/c/github/r-lib/archive/main)](https://app.codecov.io/github/r-lib/archive?branch=main)\n[![CRAN status](https://www.r-pkg.org/badges/version/archive)](https://CRAN.R-project.org/package=archive)\n\u003c!-- badges: end --\u003e\n\nR bindings to libarchive \u003chttp://www.libarchive.org\u003e.\nSupports many archives formats, including tar, ZIP, 7-zip, RAR, CAB.\nAlso supports many filters such as gzip, bzip2, compress, lzma, xz and uuencoded files, among others.\n\narchive provides interfaces to read and write connections into archives, as\nwell as efficiently reading and writing archives directly to disk.\n\n## Installation\n\nYou can install archive from CRAN with:\n\n``` r\n# install.packages(\"archive\")\n```\n\n## Example\n\n### Single file archives\n\nUse `archive_read()` and `archive_write()` to read and write single files to an archive.\nThese files return connections, which can be passed to any R interface which can take a connection.\nMost base R file system functions use connections, as well as some packages like [readr](https://readr.tidyverse.org/).\n\n```{r}\nlibrary(readr) # read_csv(), write_csv(), cols()\n\n# Write a single dataset to zip\nwrite_csv(mtcars, archive_write(\"mtcars.zip\", \"mtcars.csv\"))\n\n# Read the data back, by default the first file is read from the archive.\nread_csv(archive_read(\"mtcars.zip\"), col_types = cols())\n\n# Also supports things like archiving and compression together\n# Write a single dataset to (gzip compressed) tar\nwrite_csv(mtcars, archive_write(\"mtcars.tar.gz\", \"mtcars.csv\", options = \"compression-level=9\"))\n\n# Read the data back\nread_csv(archive_read(\"mtcars.tar.gz\"), col_types = cols())\n\n# Archive file sizes\nfile.size(c(\"mtcars.zip\", \"mtcars.tar.gz\"))\n```\n\n### Multi file archives\n\n`archive_write_files()` is used to create a new archive from multiple files on disk.\n\n```{r}\n# Write a few files to the temp directory\nwrite_csv(iris, \"iris.csv\")\nwrite_csv(mtcars, \"mtcars.csv\")\nwrite_csv(airquality, \"airquality.csv\")\n\n# Add them to a new archive\narchive_write_files(\"data.tar.xz\", c(\"iris.csv\", \"mtcars.csv\", \"airquality.csv\"))\n\n# View archive contents\na \u003c- archive(\"data.tar.xz\")\na\n\n# By default `archive_read()` will read the first file from a multi-file archive.\nread_csv(archive_read(\"data.tar.xz\"), col_types = cols())\n\n# Use a number to read a different file\nread_csv(archive_read(\"data.tar.xz\", file = 2), col_types = cols())\n\n# Or a filename to read a specific file\nread_csv(archive_read(\"data.tar.xz\", file = \"mtcars.csv\"), col_types = cols())\n```\n\n### Regular files (with compression)\n`file_write()` returns a connection to filtered by one or more compressions or\nencodings. `file_read()` reads a compressed file, automatically detecting the\ncompression used.\n\n```{r}\n# Write bzip2, uuencoded data\nwrite_csv(mtcars, file_write(\"mtcars.bz2\", filter = c(\"uuencode\", \"bzip2\")))\n\n# Read it back, the formats are automatically detected\nread_csv(file_read(\"mtcars.bz2\"), col_types = cols())\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fr-lib%2Farchive","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fr-lib%2Farchive","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fr-lib%2Farchive/lists"}