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
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. >
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