[R] How to get the list of the files when you read zip file by gzfile or unz
Prof Brian Ripley
ripley at stats.ox.ac.uk
Wed Aug 24 17:04:34 CEST 2005
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
More information about the R-help
mailing list