0

I want to import multiple csv files from FTP Server in R (R is local / on my mac). Files should be stored in an R-object, e. g. in a data.frame.

I only know how to import a single file in a dataframe:

url <- "ftp://xxx/testfolder/test.csv" 
userpwd = "xxx:yyy"
text_data <- getURL(url, userpwd = userpwd, connecttimeout = 60)
df <- read.csv(text = text_data, header = TRUE)

How can I apply it on several files. I guess applying function apply can help but I don not really know how to do it.

flobrr
  • 197
  • 1
  • 2
  • 13
  • This might help https://stackoverflow.com/a/48105838/786542 – Tung Feb 04 '19 at 17:42
  • @mako212 running last query results in "access denied". – flobrr Feb 04 '19 at 18:05
  • @ Tung Think its hardly adaptable to importing files from ftp – flobrr Feb 04 '19 at 18:06
  • @flobrr There are two key parts here, 1) retrieve multiple files from FTP 2) read in multiple `.csv` files. Tung's link probably answers the second part. – Mako212 Feb 04 '19 at 18:25
  • And you still need to provide your authentication credentials, in reference to the link – Mako212 Feb 04 '19 at 18:26
  • @Mako212. Yes, I tried a lot, but i do not get it and here is no solution to import mulltiple files from ftp that works for me – flobrr Feb 04 '19 at 18:43
  • Can you provide access to an `ftp` server that replicates your problem? If the existing solutions don't work, there is no way for anyone to test a solution without a way to reproduce the problem. – Mako212 Feb 04 '19 at 18:45
  • sorry, i can not. [https://stackoverflow.com/questions/39705379/r-downloading-multiple-file-from-ftp-using-rcurl/39706760#39706760] works till last query. Then I get error `Error in curl_download(paste(url, filename, sep = ""), destfile = filename, : Failed initialization` – flobrr Feb 04 '19 at 18:51

0 Answers0