Download .Rdata and .CSV Files from Ftp Using Rcurl (Or Any Other Method)

Download .RData and .csv files from FTP using RCurl (or any other method)

You can try breaking it into two steps: first download the file, then load it.

download.file(downloadURL, "temp.rData")
load("temp.rData")

or sticking with rCurl you can try:

bin = getBinaryURL(downloadURL, ...yourOtherParams...) 
writeBin(bin, "temp.rData")
load("temp.rData")

Download or Connect csv data from FTP wiht R

For the case of a sftp-server I use 'getURL' function from RCurl package

For your input, and an sfpt-server, the first call would download the file.

Maybe its similar for a regular ftp-connection(second call)?

# sftp
RCurl::getURL(url = "sftp://user123:Test123@example.com/my_file/example.csv")

# maybe works for a ftp connection
RCurl::getURL(url = "ftp://user123:Test123@example.com/my_file/example.csv")

hope it helps :)

Loading ftp directly to R dataframe - how to see the original text?

I found a solution, which is very simple, but works nonetheless:

library(data.table)
r <- fread("ftp://ftp.ais.dk/ais_data/aisdk_20141001.csv")

This blog was helpfull

downloading files from the secure ftp server with R

It sounds like the question is "how do I avoid timeouts in rcurl?"

Increase the value of CURLOPT_CONNECTTIMEOUT. This is really just the same problem as Setting Curl's Timeout in PHP .

Edit, from comments below:

x<-getURL(url, userpwd="<id>:<passwd>", connecttimeout=60) // 60 seconds, e.g.

Download zipped files from ftp via RCurl

Here is my solution:

library(RCurl)

url<- "ftp://adress/"
filenames <- getURL(url, userpwd="USER:PASSWORD", ftp.use.epsv = FALSE, dirlistonly = TRUE) #reading filenames from ftp-server
destnames <- filenames <- strsplit(filenames, "\r*\n")[[1]] # destfiles = origin file names
con <- getCurlHandle( ftp.use.epsv = FALSE, userpwd="USER:PASSWORD")
mapply(function(x,y) writeBin(getBinaryURL(x, curl = con, dirlistonly = FALSE), y), x = filenames, y = paste("C:\\temp\\",destnames, sep = "")) #writing all zipped files in one directory

Hopefully for anybody it's usefull!
Regards,
Florian

How to read RData file with R

This worked for me:

load(url("https://github.com/tvganesh/yorkrData/raw/master/IPL/IPL-T20-matches/Chennai%20Super%20Kings-Deccan%20Chargers-2008-05-06.RData"))

I get a dataframe overs from the RData-file.

The url is taken from the Download-button of the github-page to get the raw file.



Related Topics



Leave a reply



Submit