Reputation: 14370
I have several fairly large csv files (few millions lines), and I would like to know which one I need to load. Some of them hold GOTCHASTR
some do not. Say I way to load only the ones which hold this string, how can I test if without loading all the files and testing afterwards.
I realize it looks like a bash/grep
question but as R import some UNIX functionalities I am hoping that this can work. I am using Windows 7 + gnuWin32
Upvotes: 0
Views: 2226
Reputation:
patterns <- sapply(list.files("/your/dir", full.names=TRUE), FUN=function(x){
grep("GOTCHASTR", readLines(x))
})
Upvotes: 4