Comments (2)
Either extract all the files first, using archive::archive_extract()
and then read them as normal files, or use a loop. e.g.
library(archive)
Create a new archive
write.csv(trees, "trees.csv")
write.csv(women, "women.csv")
archive_write_files("my_archive.zip", c("trees.csv", "women.csv"))
Read each file in the archive
for (file in archive("my_archive.zip")$path) {
print(file)
print(readLines(archive_read("my_archive.zip", file)))
}
#> [1] "trees.csv"
#> [1] "\"\",\"Girth\",\"Height\",\"Volume\""
#> [2] "\"1\",8.3,70,10.3"
#> [3] "\"2\",8.6,65,10.3"
#> [4] "\"3\",8.8,63,10.2"
#> [5] "\"4\",10.5,72,16.4"
#> [6] "\"5\",10.7,81,18.8"
#> [7] "\"6\",10.8,83,19.7"
#> [8] "\"7\",11,66,15.6"
#> [9] "\"8\",11,75,18.2"
#> [10] "\"9\",11.1,80,22.6"
#> [11] "\"10\",11.2,75,19.9"
#> [12] "\"11\",11.3,79,24.2"
#> [13] "\"12\",11.4,76,21"
#> [14] "\"13\",11.4,76,21.4"
#> [15] "\"14\",11.7,69,21.3"
#> [16] "\"15\",12,75,19.1"
#> [17] "\"16\",12.9,74,22.2"
#> [18] "\"17\",12.9,85,33.8"
#> [19] "\"18\",13.3,86,27.4"
#> [20] "\"19\",13.7,71,25.7"
#> [21] "\"20\",13.8,64,24.9"
#> [22] "\"21\",14,78,34.5"
#> [23] "\"22\",14.2,80,31.7"
#> [24] "\"23\",14.5,74,36.3"
#> [25] "\"24\",16,72,38.3"
#> [26] "\"25\",16.3,77,42.6"
#> [27] "\"26\",17.3,81,55.4"
#> [28] "\"27\",17.5,82,55.7"
#> [29] "\"28\",17.9,80,58.3"
#> [30] "\"29\",18,80,51.5"
#> [31] "\"30\",18,80,51"
#> [32] "\"31\",20.6,87,77"
#> [1] "women.csv"
#> [1] "\"\",\"height\",\"weight\"" "\"1\",58,115"
#> [3] "\"2\",59,117" "\"3\",60,120"
#> [5] "\"4\",61,123" "\"5\",62,126"
#> [7] "\"6\",63,129" "\"7\",64,132"
#> [9] "\"8\",65,135" "\"9\",66,139"
#> [11] "\"10\",67,142" "\"11\",68,146"
#> [13] "\"12\",69,150" "\"13\",70,154"
#> [15] "\"14\",71,159" "\"15\",72,164"
Created on 2021-10-21 by the reprex package (v2.0.1)
from archive.
Thanks that got it working!
from archive.
Related Issues (20)
- Release archive 1.1.2
- Encourage using "data.table" functions over CSV helpers in the documentation HOT 3
- Locale problem HOT 6
- Typo in `archive()` doc --- #' @returns @return A [tibble][tibble::tibble-package] with ...
- Release archive 1.1.3
- R-devel crashes on Windows 2022 HOT 1
- archive_write_dir() creates empty archive HOT 1
- Release archive 1.1.4
- `archive_extract()` not working for files compress using `data.table::fwrite()` HOT 1
- Can't roundtrip a filepath with non-ascii characters in a non-UTF-8 locale HOT 1
- Can I change session timeout time length? HOT 1
- Possible to read from a multi-file archive?
- Blank lib_path in R/zzz.R in Mac OS X conda environment HOT 1
- archive_extract fails on 7-zip archives > 2 GB HOT 2
- archive_read.cpp does not include required defines for Big-endian platforms HOT 3
- archive_extract keeps working after extracting the desired files from remote .zip HOT 4
- Unsupported ZIP compression method (deflation-64-bit)
- Suggest adding new `archive_extract_filter` which uses `fs::path_filter` HOT 3
- Error with .7z file "The file content is encrypted, but currently not supported"
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from archive.