[R] read and process files line by line

Gabor Grothendieck ggrothendieck at gmail.com
Sat Feb 6 23:00:49 CET 2010


Check this:

https://stat.ethz.ch/pipermail/r-help/2009-March/192942.html

On Sat, Feb 6, 2010 at 4:57 PM, Dick Harray <tomdharray at gmail.com> 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()
>
>  # { 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
>
> ______________________________________________
> R-help at 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.
>



More information about the R-help mailing list