Reputation: 12112
Is it possible to process text stream in R similar to awk
or sed
in linux? The idea is to read in line by line, process and then write to file, without having to read in the whole file to memory.
Any examples or links to such an approach is highly appreciated. Thanks.
Upvotes: 4
Views: 1014
Reputation: 4993
Indeed there is! You can use readLines()
which is a part of the base package in R. You can import a text file, post a string or open a connecting to a webpage.
Check it out here:
readLines in Cran
Upvotes: 1