I want to select some portion from file1.txt
and save that in another file named file2.txt
.
File1.txt:
abc 1 6 a
abc 2 7 b
efg 3 8 c
abc 4 9 d
efg 5 10 e
Database query that I want to apply here is (not syntax specific):
file2.txt <- select col2, col3, col4 from file1.txt where col1=abc
File2.txt:
1 6 a
2 7 b
4 9 d
Is there any way to apply database type query in R on a text file? I know that we can search a letter in .txt file by using grep()
function. But I'm unable to find any online help for this? Does anyone know how can I resolve my problem? Thank you in advance :)
Please don't mark this question duplicate to:
This question is something different. Moreover I cannot use sqldf
because this package is not for .txt files.