[R] Add header line to large text file

Zev Ross zev at zevross.com
Thu Apr 15 16:34:55 CEST 2010


All,

I have a 30 million record text file without header information. I would 
like to add a header to this file without reading it first. Is this 
possible? The code below does what I want except that the readLines 
portion takes quite a long time. Is there a way around reading the 
lines? I'm working on Windows XP.

Zev

input<-readLines("c:/junk/forR.csv")
input<-c(c('"a", "b", "c", "d", "e", "f"'), input)
writeLines(input, "c:/junk/forRfix.csv")

-- 
Zev Ross
ZevRoss Spatial Analysis
120 N Aurora, Suite 3A
Ithaca, NY 14850
607-277-0004 (phone)
866-877-3690 (fax, toll-free)
zev at zevross.com



More information about the R-help mailing list