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
Take a look on ?file_test
On Tue, Nov 30, 2010 at 2:10 PM, 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
?file.exists
On Tue, Nov 30, 2010 at 11: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
Neither file_test nor file.exists address the OP question, since
both of these depend on the filesystem stat call, which doesn't work
via arbitrary remote access protocols such as http.
Baoqiang Cao: The simplest answer is that if you want the file, try
to download it, and deal with any error
I would use RCurl.
if you have, for example, the url of an ftp site you can merely do a
getURL() and the contents will be returned. That call will return data that
can be coerced into a data.frame that will look like a directory structure
listing the file names.
If you need code just ask, but
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
Thanks Steven!
It is excellent code indeed!
On Tue, Nov 30, 2010 at 11:26 AM, steven mosher mosherste...@gmail.com wrote:
I would use RCurl.
if you have, for example, the url of an ftp site you can merely do a
getURL() and the contents will be returned. That call will return data that
can
No problem, you can also get the directory with a curlOption of dirlistonly
see the example code in the package. This will depend on the version of
libcurl that you have.
If you have an older version, my code will get you the directory.
From the Rcurl examples:
the files within a directory.
Thanks Steven again!
I have to say that these codes are fairly sophisticated to me, but I
enjoy using already!
BC
On Tue, Nov 30, 2010 at 12:02 PM, steven mosher mosherste...@gmail.com wrote:
No problem, you can also get the directory with a curlOption of dirlistonly
see the example code in
On 30/11/10 10:10:07, Baoqiang Cao wrote:
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?
Hi
here:
getFtpList - function(ftp){
# 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(
Hi Georg,
Your code does work, I mean, it doesn't give me any error message,
which is critical for me because I need use it in a loop and plus I
don't know how to catch error message. Before your message, I was
using download.file but the loop was stopped because of the error
message when a file
study trycatch()
also, be awre that even with RCurl, that you may find the file there and
then fail or lose
the connection.
worse still you may get a currupt file on download. So there is a lot of
checking to do
to make bullet proof code that downloads files.
On Tue, Nov 30, 2010 at 3:16
I must say that your reminder is exactly what happened on me, that is,
the file is there but some of the downloaded files are corrupted. The
download.file didn't return anything alarming, but just could't open
some files. The problem was solved in my case by turning on
method=wget.
Thanks again!
14 matches
Mail list logo