using RCurl

getFtpList <- function(ftp){

    # the structure returned is dependent on the ftp site as there are
    # various formats for directory listings dependent upon the server
    # and the OS. you will need to play with this.
    # have a look at the ftp with your browser first and adjust accordingly.
    # some formats only return 4 columns.
    # column 1= literal string first position mean file
    # column 2= number 1
    # column 3 =owner
    # column 4 = group
    # column 5 =file size
    # colmn  6 =Month
    # column 7 =Day
    # column 8 =Time (year)
    # column 9 =FileName
    #
    txt <- getURL(ftp)

    dir <- read.table( textConnection(txt),as.is=TRUE)
    out <- data.frame(Dir=ftp,Filename=dir[, ncol(dir)],Size=dir[ ,5],
                      Month=dir[ ,6],Day=dir[ ,7],Time=dir[
,8],stringsAsFactors=FALSE)
    closeAllConnections()
    return(out)
}

On Tue, Nov 30, 2010 at 8:10 AM, Baoqiang Cao <bqcaom...@gmail.com> wrote:

> Hi,
>
> I'd like to download some data files from a remote server, the problem
> here is that some of the files actually don't exist, which I don't
> know before try. Just wondering if a function in R could tell me if a
> file exists on a remote server? I searched this mailing list and after
> read severals mails, still clueless.  Any help will be highly
> appreciated.
>
> B.C.
>
> ______________________________________________
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to