Hi, Is there a way to check whether a file is empty in R. I did the customary searches, but did not find anything. Please cc me on any reply. Thanks, Faheem.
help(file.info). /Henrik On Wed, Apr 30, 2008 at 5:33 PM, Faheem Mitha <faheem at email.unc.edu> wrote:> > Hi, > > Is there a way to check whether a file is empty in R. I did the customary > searches, but did not find anything. Please cc me on any reply. > Thanks, Faheem. > > ______________________________________________ > 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. >
What is wrong with> file.create("foo")[1] TRUE> file.info("foo")$size[1] 0> file.remove("foo")? I really wonder what searches you did: help.search("file") come up with file.info. On Wed, 30 Apr 2008, Faheem Mitha wrote:> Is there a way to check whether a file is empty in R. I did the customary > searches, but did not find anything. Please cc me on any reply. > Thanks, Faheem.-- 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
On Wed, Apr 30, 2008 at 11:33:01AM -0400, Faheem Mitha wrote:> Is there a way to check whether a file is empty in R. I did the customary > searches, but did not find anything. Please cc me on any reply.Empty file have, by definition, a size of zero, so here's one way:> system("touch /tmp/faheem") > file.info("/tmp/faheem")$size == 0[1] TRUE Hth, Dirk -- Three out of two people have difficulties with fractions.