Hi, I wanted to download a file and did the following: ---------------------------------------------------------> fileLink <- 'ftp://ftp.ncbi.nih.gov/pub/geo/DATA/supplementary/series/GSE1000/GSE1000_RAW.tar' > download.file(fileLink,'/geoDat')trying URL 'ftp://ftp.ncbi.nih.gov/pub/geo/DATA/supplementary/series/GSE1000/GSE1000_RAW.tar' ftp data connection made, file length 35307520 bytes opened URL downloaded 34480Kb>------------------------------------------------------------ However, when I look in the destination directory ('/geoDat'), the file is not there (I also tried giving it the absolute path). What am I doing wrong? thanks! ____________________________________________________________________________________ Be a better friend, newshound, and [[alternative HTML version deleted]]
On Tue, Mar 18, 2008 at 8:46 AM, Paul Evans <p.evans48 at yahoo.com> wrote:> Hi, > > I wanted to download a file and did the following: > --------------------------------------------------------- > > fileLink <- 'ftp://ftp.ncbi.nih.gov/pub/geo/DATA/supplementary/series/GSE1000/GSE1000_RAW.tar' > > download.file(fileLink,'/geoDat') > trying URL 'ftp://ftp.ncbi.nih.gov/pub/geo/DATA/supplementary/series/GSE1000/GSE1000_RAW.tar' > ftp data connection made, file length 35307520 bytes > opened URL > downloaded 34480Kb > > > > ------------------------------------------------------------ > > However, when I look in the destination directory ('/geoDat'), the file is not there (I also tried giving it the absolute path). > > What am I doing wrong?I'm quite sure the 'destfile' argument of download.file() is a file not a directory. Example:> download.file("http://www.r-project.org/index.html", destfile="foo.html") > file.info("foo.html")size isdir mode mtime ctime foo.html 785 FALSE 666 2008-03-18 08:54:19 2008-03-18 08:54:11 atime exe foo.html 2008-03-18 08:54:19 no So you probably saved the downloaded file as 'geoDat' in the root directory '/'. /Henrik> > thanks! > > > > > ____________________________________________________________________________________ > Be a better friend, newshound, and > > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at 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. >
On Tuesday 18 March 2008 04:46:12 pm Paul Evans wrote: PE> > download.file(fileLink,'/geoDat') I would have expected download.file(fileLink,"/geoDat/yourfilename") note that you need your complete path (or use setwd) -- Microeconomics University of Erfurt -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 189 bytes Desc: This is a digitally signed message part. Url : https://stat.ethz.ch/pipermail/r-help/attachments/20080318/e938bdf2/attachment-0001.bin
Aaah...I see now. Thanks !! ----- Original Message ---- From: Henrik Bengtsson <hb@stat.berkeley.edu> To: Paul Evans <p.evans48@yahoo.com> Cc: r-help@stat.math.ethz.ch Sent: Tuesday, March 18, 2008 11:59:45 AM Subject: Re: [R] download.file() On Tue, Mar 18, 2008 at 8:57 AM, Henrik Bengtsson <hb@stat.berkeley.edu> wrote:> On Tue, Mar 18, 2008 at 8:46 AM, Paul Evans <p.evans48@yahoo.com> wrote: > > Hi, > > > > I wanted to download a file and did the following: > > --------------------------------------------------------- > > > fileLink <- 'ftp://ftp.ncbi.nih.gov/pub/geo/DATA/supplementary/series/GSE1000/GSE1000_RAW.tar' > > > download.file(fileLink,'/geoDat') > > trying URL 'ftp://ftp.ncbi.nih.gov/pub/geo/DATA/supplementary/series/GSE1000/GSE1000_RAW.tar' > > ftp data connection made, file length 35307520 bytes > > opened URL > > downloaded 34480Kb > > > > > > > ------------------------------------------------------------ > > > > However, when I look in the destination directory ('/geoDat'), the file is not there (I also tried giving it the absolute path). > > > > What am I doing wrong? > > I'm quite sure the 'destfile' argument of download.file() is a file > not a directory. Example: > > > download.file("http://www.r-project.org/index.html", destfile="foo.html") > > file.info("foo.html") > size isdir mode mtime ctime > foo.html 785 FALSE 666 2008-03-18 08:54:19 2008-03-18 08:54:11 > atime exe > foo.html 2008-03-18 08:54:19 no > > So you probably saved the downloaded file as 'geoDat' in the root > directory '/'.Also, you want to download the file in a binary fashion, i.e. use argument mode="wb", otherwise your binary tar file will be corrupt. R-core: I'd suggest to replace the default to mode="wb" for file transfers. /Henrik> > /Henrik > > > > > > > > thanks! > > > > > > > > > > ____________________________________________________________________________________ > > Be a better friend, newshound, and > > > > > > [[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. > > >____________________________________________________________________________________ Looking for last minute shopping deals? [[alternative HTML version deleted]]
/geodat *is* an absoute path! The second argument of download.file is called 'destfile', so what makes you think it is a desination *directory*? Your command works for me, using an account that has write permission in / , and not otherwise. (It seems very unsafe that you would be using such an account unless this is a pre-Vista Windows machine.) On Tue, 18 Mar 2008, Paul Evans wrote:> Hi, > > I wanted to download a file and did the following: > --------------------------------------------------------- >> fileLink <- 'ftp://ftp.ncbi.nih.gov/pub/geo/DATA/supplementary/series/GSE1000/GSE1000_RAW.tar' >> download.file(fileLink,'/geoDat') > trying URL 'ftp://ftp.ncbi.nih.gov/pub/geo/DATA/supplementary/series/GSE1000/GSE1000_RAW.tar' > ftp data connection made, file length 35307520 bytes > opened URL > downloaded 34480Kb > >> > ------------------------------------------------------------ > > However, when I look in the destination directory ('/geoDat'), the file > is not there (I also tried giving it the absolute path). > > What am I doing wrong?Not reading the help page?> thanks! > > > > > ____________________________________________________________________________________ > Be a better friend, newshound, and > > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at 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. >-- Brian D. Ripley, ripley at stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UK Fax: +44 1865 272595
Thanks Henrik. Also, is there a method/package (in R) with which I can unpack a tar file programatically? thanks again! ----- Original Message ---- From: Henrik Bengtsson <hb@stat.berkeley.edu> To: Prof Brian Ripley <ripley@stats.ox.ac.uk> Cc: Paul Evans <p.evans48@yahoo.com>; r-help@stat.math.ethz.ch Sent: Tuesday, March 18, 2008 12:38:14 PM Subject: Re: [R] download.file() On Tue, Mar 18, 2008 at 9:10 AM, Prof Brian Ripley <ripley@stats.ox.ac.uk> wrote:> /geodat *is* an absoute path! > > The second argument of download.file is called 'destfile', so what makes > you think it is a desination *directory*?The help file might be the source of confusion: "destfile: A character string with the name where the downloaded file is saved. Tilde-expansion is performed." ....especially the word "where". Better with "A character string specifying the name [pathname?] of the saved file" is better. /Henrik> > Your command works for me, using an account that has write permission in / > , and not otherwise. (It seems very unsafe that you would be using such > an account unless this is a pre-Vista Windows machine.) > > > > On Tue, 18 Mar 2008, Paul Evans wrote: > > > Hi, > > > > I wanted to download a file and did the following: > > --------------------------------------------------------- > >> fileLink <- 'ftp://ftp.ncbi.nih.gov/pub/geo/DATA/supplementary/series/GSE1000/GSE1000_RAW.tar' > >> download.file(fileLink,'/geoDat') > > trying URL 'ftp://ftp.ncbi.nih.gov/pub/geo/DATA/supplementary/series/GSE1000/GSE1000_RAW.tar' > > ftp data connection made, file length 35307520 bytes > > opened URL > > downloaded 34480Kb > > > >> > > ------------------------------------------------------------ > > > > However, when I look in the destination directory ('/geoDat'), the file > > is not there (I also tried giving it the absolute path). > > > > What am I doing wrong? > > Not reading the help page? > > > > thanks! > > > > > > > > > > ____________________________________________________________________________________ > > Be a better friend, newshound, and > > > > > > [[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. > > > > -- > Brian D. Ripley, ripley@stats.ox.ac.uk > Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ > University of Oxford, Tel: +44 1865 272861 (self) > 1 South Parks Road, +44 1865 272866 (PA) > Oxford OX1 3TG, UK Fax: +44 1865 272595 > > > > ______________________________________________ > 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. >____________________________________________________________________________________ Looking for last minute shopping deals? [[alternative HTML version deleted]]
On Tuesday 18 March 2008 06:32:18 pm Paul Evans wrote: PE> Also, is there a method/package (in R) with which I can unpack a tar file PE> programatically? I guesses that question when I saw your tar file. Not that you not only need to un-tar but also to un-zip then several other files in that tarball. Counter-question: is it necessary that you do all that from within R? You could manually download, untar/unzip and then read the data that will be your next problem: the files have different names and some other information then just a table ... So unless you want to extract a lot of separate tables I think it is easier to do it manually. Stefan -- Microeconomics University of Erfurt
Stefan, Correct. However I have a large number of tar files to download (with several zip files in each) - so doing it manually is going to be somewhat difficult. I may have to package this code for other users and if possible, would only like to use R for these operations. thanks for the reply! ----- Original Message ---- From: Stefan Grosse <singularitaet@gmx.net> To: r-help@r-project.org; Paul Evans <p.evans48@yahoo.com> Sent: Tuesday, March 18, 2008 1:57:46 PM Subject: Re: [R] download.file() On Tuesday 18 March 2008 06:32:18 pm Paul Evans wrote: PE> Also, is there a method/package (in R) with which I can unpack a tar file PE> programatically? I guesses that question when I saw your tar file. Not that you not only need to un-tar but also to un-zip then several other files in that tarball. Counter-question: is it necessary that you do all that from within R? You could manually download, untar/unzip and then read the data that will be your next problem: the files have different names and some other information then just a table ... So unless you want to extract a lot of separate tables I think it is easier to do it manually. Stefan -- Microeconomics University of Erfurt ____________________________________________________________________________________ Be a better friend, newshound, and [[alternative HTML version deleted]]