Shawn Lee
2005-Aug-24 14:41 UTC
[R] How to get the list of the files when you read zip file by gzfile or unz
Dear List, Does somebody know how to get the filename lists in the ziped when "gzfile" or "unz" command is used ? Thanks for your help. Shawn Lee -- The information contained in this communication and any atta...{{dropped}}
Prof Brian Ripley
2005-Aug-24 15:04 UTC
[R] How to get the list of the files when you read zip file by gzfile or unz
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