for (i in fileList){ x <- read.csv(i) x$QID <- "" x$COMMENTS <- "" x$"DATE CREATED" <- "" write.csv(x, file = i) }
Sent from my iPad On Mar 19, 2012, at 17:42, Edgar Alminar <eaalmi...@ucsd.edu> wrote: > Hello, > I am trying to add columns to a folder of csvs (the folder is called > "20120314"). > I have csvs of different numbers of columns, but at the end of this loop, I'd > like to add three columns to each csv: "QID", "COMMENTS", "DATE CREATED". > I've tried some things with cbind, I looked at using awk, but I couldn't get > either to work. > > Does anyone have an example of a working loop that adds columns to a folder > of csvs? > > Thanks! > Edgar > ______________________________________________ > R-help@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. ______________________________________________ R-help@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.