[R] read and process files line by line

Dick Harray tomdharray at gmail.com
Sat Feb 6 22:57:58 CET 2010

Hi there,

I want to read large files line by line in order to process each line
and store the information of each list iin an object. My problem is,
that I do not know how to process each line of the file, because I
want to avoid to import the whole file.

The data file "inputdata.csv" is a CSV file with a header like:
Number, Name, factors1, factors2
"123", "some characters", "a; list; of; factors", "a; second; list; of; factors"

How can I read the file in a manner like:

foreach_line_in("inputdata.csv") {
  currentline <- function_or_command_to_get_the_current_line()

  # { here comes the block in which the current line is processed, and
the new object created
  #  no help needed here}


Thanks and regards,

More information about the R-help mailing list