Roger Peng
2007-Sep-26 17:54 UTC
[Rd] Lack of final newline in write.dcf changes append usage
The change in r42731 eliminating the final blank line when writing DCF files changes the way 'append' can be used in 'write.dcf' and I was wondering if this is intentional. Basically, I want to write a data frame to DCF format one row at a time, so I make use of repeated calls to 'write.dcf(append = TRUE)'. However, in R 2.6.0RC the resulting DCF file is not formatted properly because there are no blank lines between the entries. It seems the only way to use 'write.dcf(append = TRUE)' is to explicitly write a blank line to the file before writing the entry. Perhaps 'write.dcf' could be changed to write a blank line in the beginning if append = TRUE? I've attached a patch for this possibility. -roger -- Roger D. Peng | http://www.biostat.jhsph.edu/~rpeng/
Prof Brian Ripley
2007-Sep-26 18:50 UTC
[Rd] Lack of final newline in write.dcf changes append usage
On Wed, 26 Sep 2007, Roger Peng wrote:> The change in r42731 eliminating the final blank line when writing DCF > files changes the way 'append' can be used in 'write.dcf' and I was > wondering if this is intentional. Basically, I want to write a dataYes, it is intentional. That a blank line got written after a single record (only) was regarded as unintentional: blank lines are (I was told) record separators and not terminators.> frame to DCF format one row at a time, so I make use of repeated calls > to 'write.dcf(append = TRUE)'. However, in R 2.6.0RC the resulting DCF > file is not formatted properly because there are no blank lines > between the entries.tools::write_PACKAGES had that problem. But surely it is better to keep a connection open and make repeated calls to write.dcf on it (as write_PACKAGES does). I don't think writing record separators explicitly is much of a hardship.> It seems the only way to use 'write.dcf(append = TRUE)' is to > explicitly write a blank line to the file before writing the entry.or after an entry.> Perhaps 'write.dcf' could be changed to write a blank line in the > beginning if append = TRUE? I've attached a patch for this > possibility.Not in code freeze, and in any case it does not address what for me is the natural usage. -- 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
Reasonably Related Threads
- tools:: extracting pkg dependencies from DCF
- Error in read.dcf(file = tmpf) : Line starting '<head> ...' is malformed!
- tools:: extracting pkg dependencies from DCF
- (PR#9796) write.dcf/read.dcf cycle converts missing entry
- Read.dcf with no newline ending: gzfile drops last line