I need to sftp get bunch of files and and parse them and get rid of unwanted lines and form a data frame. Is it possible to sftp get bunch of files from remote ftp server and process these txt files in R?
This is what I have tried so far but I get authentication error:
library(RCurl)
url="sftp://ftp.address.com/directory"
filenames = getURL(url, ftp.use.epsv = FALSE, ftplistonly = TRUE)
filenames = paste(url, strsplit(filenames, "\n")[[1]], sep = "")
con = getCurlHandle( ftp.use.epsv = FALSE)
sapply(filenames, getURL, curl = con)
I get this error:
Error in function (type, msg, asError = TRUE) : Could not resolve host: sftp:; No data record of requested type
ok, I have done this and it is sort of working.
getURL("sftp://site.com/filename.txt", userpwd="id:passed")
I am not done yet. I need the output of getURL to be written to a file so that I can do readLines on the file to parse the unwanted lines and etc.