[R] Add header line to large text file
Zev Ross
zev at zevross.com
Thu Apr 15 18:35:12 CEST 2010
Thanks to Wensui Liu and Jim Holtman for responses. Using sed was a good,
quick (non-R) suggestion. Thanks! Zev
Wensui Liu wrote:
if i were you, i probably will use 1 line of sed to do such task
instead of R to insert headers in the file.
On Thu, Apr 15, 2010 at 10:34 AM, Zev Ross [1]<zev at zevross.com> wrote:
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)
[2]zev at zevross.com
______________________________________________
[3]R-help at r-project.org mailing list
[4]https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide [5]http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
--
Zev Ross
ZevRoss Spatial Analysis
120 N Aurora, Suite 3A
Ithaca, NY 14850
607-277-0004 (phone)
866-877-3690 (fax, toll-free)
[6]zev at zevross.com
References
1. mailto:zev at zevross.com
2. mailto:zev at zevross.com
3. mailto:R-help at r-project.org
4. https://stat.ethz.ch/mailman/listinfo/r-help
5. http://www.R-project.org/posting-guide.html
6. mailto:zev at zevross.com
More information about the R-help
mailing list