Re: [R] How to get the list of the files when you read zip file by gzfile or unz

From: Prof Brian Ripley <>
Date: Thu 25 Aug 2005 - 01:04:34 EST

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,        
Professor of Applied Statistics,
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595

______________________________________________ mailing list
PLEASE do read the posting guide!
Received on Thu Aug 25 01:10:11 2005

This archive was generated by hypermail 2.1.8 : Sun 23 Oct 2005 - 15:49:54 EST