GithubHelp home page GithubHelp logo

Comments (2)

jimhester avatar jimhester commented on June 12, 2024 1

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.

T145 avatar T145 commented on June 12, 2024

Thanks that got it working!

from archive.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.