How to programmatically extract / unzip a .7z (7-zip) file with R

前端 未结 2 591
Happy的楠姐
Happy的楠姐 2020-12-04 18:18

I\'m trying to automate the extraction of a number of files compressed with 7-zip. I need to automate this process, because a) there are many years of data I\'d like to unl

相关标签:
2条回答
  • 2020-12-04 18:55

    If you have 7z executable in your path, you can simple use system command

    system('7z e -o <output_dir> <archive_name>')

    0 讨论(0)
  • 2020-12-04 18:59

    This can be done with the archive package.

    library(archive)
    tf <- tempfile() ; td <- tempdir()
    file.path <- "ftp://ftp.ibge.gov.br/Orcamentos_Familiares/Pesquisa_de_Orcamentos_Familiares_2008_2009/Microdados/Dados.zip"
    download.file( file.path , tf , mode = "wb" )
    archive(tf)
    

    See https://github.com/jimhester/archive

    0 讨论(0)
提交回复
热议问题