try this: (?try) name_c<-Sys.glob("C:/Documents and Settings/lma/My Documents/habitdata/*/calllog/*")
for (i in 1:length(name_c)){ log1<-try(readLines(name_c[i])) if (inherits(log1, 'try-error')) next # skip if error .... write.table(Temps, file=paste("C:/Documents and Settings/lma/My Documents/habitdata1",pname,lname,basename(name_c[i]),sep="/")) } On Fri, Oct 2, 2009 at 7:04 AM, Tammy Ma <metal_lical...@live.com> wrote: > > Hi, R-users, > > > I have a problem: Because there are few files which can't be readed > into R completely, so on the following subsequence programme, I use > write.table, which creates the "NA" files for those incomplete files > autimatically. > I don't want those NA files. > > My programes formats looks like: > > > > name_c<-Sys.glob("C:/Documents and Settings/lma/My > Documents/habitdata/*/calllog/*") > > for (i in 1:length(name_c)){ > > log1<-readLines(name_c[i]) > .... > > write.table(Temps, file=paste("C:/Documents and Settings/lma/My > Documents/habitdata1",pname,lname,basename(name_c[i]),sep="/")) > > } > > > Error Information: > Error in file(file, ifelse(append, "a", "w")) : > cannot open the connection > > In file(file, ifelse(append, "a", "w")) : > cannot open file 'C:/Documents and Settings/lma/My > Documents/habitdata1/NA/NA/NA': Permission denied > > > I have checked why the error appears, because when I use "readLines" to read > data, but when processing the large data set, there are few files which can > not be readed in completely: > > 48: In readLines(name_c[i]) ... : > > incomplete final line found on 'C:/Documents and Settings/lma/My > Documents/habitdata/244052900243997/calllog/calllog_log-20050505T121611.txt' > ... > > > So it create the "NA" file when implementing the subsequence procedure by > write.table.How can I do: whenever readLines can't completely read one file, > then autimatically doesn't implement the subsequence programmes? > > Thanks. > Tammy > _________________________________________________________________ > More than messages–check out the rest of the Windows Live™. > http://www.microsoft.com/windows/windowslive/ > [[alternative HTML version deleted]] > > > ______________________________________________ > 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. > > -- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem that you are trying to solve? ______________________________________________ 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.