Attempting to download files from SFTP using R

前端 未结 3 1516
别跟我提以往
别跟我提以往 2021-01-15 05:50

I\'m trying to implement R in the workplace and save a bit of time from all the data churning we do.

A lot of files we receive are sent to us via SFTP as they contai

相关标签:
3条回答
  • 2021-01-15 06:09

    I too was having problems specifying the port options when using the getURI() and getURL() functions.

    In order to specify the port, you simply add the port as port = #### instead of port(####). For example:

    data <- getURI(url = url,
                   userpwd = userpwd,
                   port = 22)
    

    Now, like @MarkThomas pointed out, whenever you get an encodoing error, try getBinaryURL() instead of getURI(). In most cases, this will allow you to download SAS files as well as .csv files econded in UTF-8 or LATIN1!!

    0 讨论(0)
  • 2021-01-15 06:26

    Note that there are two packages, RCurl and rcurl. For RCurl, I used successfully keyfiles to connect via sftp:

    opts <- list(
        ssh.public.keyfile = pubkey, # file name
        ssh.private.keyfile = privatekey, # filename
        keypasswd <- keypasswd # optional password
    ) 
    RCurl::getURL(url=uri, .opts = opts, curl = RCurl::getCurlHandle())
    

    For this to work, you need two create the keyfiles e.g. via putty or similar.

    0 讨论(0)
  • 2021-01-15 06:29

    Looks like a similar situation here: Using R to download SAS file from ftp-server

    I'm no expert in r but there it looks like getBinaryUrl() worked instead of getURL() in the example given.

    Hope that helps M

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