Skip to content
Back to formatted view

Raw Message

Message-ID: <Pine.LNX.4.61.0508241557240.16717@gannet.stats>
Date: 2005-08-24T15:04:34Z
From: Brian Ripley
Subject: How to get the list of the files when you read zip file by gzfile or unz
In-Reply-To: <C26DF8487E6ED540B0B9163433BD2C9878BB8B@NLVDHX84.sn-eu.asml.com>

On Wed, 24 Aug 2005, Shawn Lee wrote:

> Does somebody know how to get the filename lists in the ziped when
> "gzfile" or "unz" command is used ?

There is no list when gzfile() is used: a gzipped file is not a zip
archive.

unz() opens a single specified file in a zip archive.

AFAIK R does not directly support listing files in a zip archive as R
itself has no need of this.  However,

   tmp <- system(paste("unzip -l", zip_file_name), intern=TRUE)
   substring(tmp[-c(1:3, length(tmp)-0:1)], 29)

looks about right.

-- 
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