Downloading large files with R/RCurl efficiently

前端 未结 2 596
陌清茗
陌清茗 2020-12-28 08:24

I see that many examples for downloading binary files with RCurl are like such:

library(\"RCurl\")
curl = getCurlHandle()
bfile=getBinaryURL (
        \"http         


        
2条回答
  •  醉梦人生
    2020-12-28 08:48

    um.. use mode = 'wb' :) ..run this and follow along w/ my comments.

    # create a temporary file and a temporary directory on your local disk
    tf <- tempfile()
    td <- tempdir()
    
    # run the download file function, download as binary..  save the result to the temporary file
    download.file(
        "http://sourceforge.net/projects/peazip/files/4.8/peazip_portable-4.8.WINDOWS.zip/download",
        tf ,
        mode = 'wb' 
    )
    
    # unzip the files to the temporary directory
    files <- unzip( tf , exdir = td )
    
    # here are your files
    files
    

提交回复
热议问题