search for: iteratefil

Displaying 1 result from an estimated 1 matches for "iteratefil".

Did you mean: iteratefile
2009 Oct 13
1
Iterating over file lines
I am attempting to iterate over a file, processing it line by line. In my function below, I am only getting the first item over and over and over again from my test file rather than subsequent lines. How can I modify this to read lines sequentially? == iteratefile <- function(file) { f.con <- file(file) on.exit(close(f.con)) while( length(readln <- readLines(f.con, 1)) > 0 ) { x <- unlist(strsplit(readln, " ")) print(x[1]) } return(invisible()) } iteratefile("test.txt") == I am working with version...