From hpages at fhcrc.org  Fri Dec  7 00:41:41 2012
From: hpages at fhcrc.org (=?ISO-8859-1?Q?Herv=E9_Pag=E8s?=)
Date: Thu, 06 Dec 2012 15:41:41 -0800
Subject: [Rd] Comments in the DESCRIPTION file
In-Reply-To: <509A2FAA.1030404@gmail.com>
References: <509A2942.3050004@u-paris10.fr> <509A2FAA.1030404@gmail.com>
Message-ID: <50C12D35.9000706@fhcrc.org>

Hi,

Wouldn't be hard to patch read.dcf() though.

FWIW here's the "comment aware" version of read.dcf() I've been using
for years:

   .removeCommentLines <- function(infile=stdin(), outfile=stdout())
   {
     if (is.character(infile)) {
         infile <- file(infile, "r")
         on.exit(close(infile))
     }
     if (is.character(outfile)) {
         outfile <- file(outfile, "w")
         on.exit({close(infile); close(outfile)})
     }
     while (TRUE) {
         lines <- readLines(infile, n=25000L)
         if (length(lines) == 0L)
             return()
         keep_it <- substr(lines, 1L, 1L) != "#"
         writeLines(lines[keep_it], outfile)
     }
   }

   read.dcf2 <- function(file, ...)
   {
     clean_file <- file.path(tempdir(), "clean.dcf")
     .removeCommentLines(file, clean_file)
     on.exit(file.remove(clean_file))
     read.dcf(clean_file, ...)
   }

Cheers,
H.

On 11/07/2012 01:53 AM, Duncan Murdoch wrote:
> On 12-11-07 4:26 AM, Christophe Genolini wrote:
>> Hi all,
>>
>> Is it possible to add comments in the DESCRIPTION file?
>
>
> The read.dcf function is used to read the DESCRIPTION file, and it
> doesn't support comments.  (The current Debian control format
> description does appear to support comments with leading # markers, but
> R's read.dcf function doesn't support these.)
>
> You could probably get away with something like
>
> #: this is a comment
>
> since unrecognized fields are ignored, but I think this fact is
> undocumented so I would say it's safer to assume that comments are not
> supported.
>
> Duncan Murdoch
>
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel

-- 
Herv? Pag?s

Program in Computational Biology
Division of Public Health Sciences
Fred Hutchinson Cancer Research Center
1100 Fairview Ave. N, M1-B514
P.O. Box 19024
Seattle, WA 98109-1024

E-mail: hpages at fhcrc.org
Phone:  (206) 667-5791
Fax:    (206) 667-1319



[Rd] Comments in the DESCRIPTION file
=?ISO-8859-1?Q?Herv=E9_Pag=E8s?=