[R] Reading zipped data directly from an FTP url

Prof Brian Ripley ripley at stats.ox.ac.uk
Thu Oct 9 12:15:23 CEST 2008


On Thu, 9 Oct 2008, michael watson (IAH-C) wrote:

> Hi
>
> Sorry, I am clearly missing something here.

Yes, you need to use unz() for a zip file, and it does not handle urls 
(only url does).  So download the file (download.file()) first.

>
> I want to read this file directly:
> ftp://ftp.sanger.ac.uk/pub/mirbase/targets/v5/arch.v5.txt.gallus_gallus.
> zip
>
> I tried using
>
> read.table(gzfile("ftp://ftp.sanger.ac.uk/pub/mirbase/targets/v5/arch.v5
> .txt.gallus_gallus.zip"))
>
> But I got an error:
>
> Error in open.connection(file, "r") : cannot open the connection
> In addition: Warning message:
> In open.connection(file, "r") :
>  cannot open compressed file
> 'ftp://ftp.sanger.ac.uk/pub/mirbase/targets/v5/arch.v5.txt.gallus_gallus
> .zip', probable reason 'No such file or directory'
>
> With all the different ways of opening connections (url(), unz(),
> gzfile(), gzcon() etc) I am just getting a bit lost.  The above zip
> archive contains a single tab-delimited file, but one which I need to
> skip the first 5 lines.
>
> Any help appreciated!
>
> Thanks
> Mick
>
> ______________________________________________
> 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



More information about the R-help mailing list