[R] read and process files line by line

David Winsemius dwinsemius at comcast.net
Sun Feb 7 02:18:39 CET 2010


On Feb 6, 2010, at 4:57 PM, Dick Harray wrote:

> 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()

?readLines

>
>  # { here comes the block in which the current line is processed, and
> the new object created
>  #  no help needed here}
>
> }
>
> Thanks and regards,
> d!rk

__

David Winsemius, MD
Heritage Laboratories
West Hartford, CT



More information about the R-help mailing list