Created
September 8, 2011 20:39
-
-
Save killerswan/1204618 to your computer and use it in GitHub Desktop.
filtering a large file with a list of things
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
open System | |
open System.IO | |
// use an @ string | |
let list = @"C:\list.txt" | |
// initialize a reader | |
let reader = new StreamReader(list) | |
// create a list of lines | |
let lines = [ while not reader.EndOfStream do | |
yield reader.ReadLine () ] | |
// filter to only the version we care about, by string match | |
let isolateVersion (s: string) (a: string) = a.Contains(s) | |
// filter and then print each line | |
lines | |
|> List.filter (isolateVersion @"MYKEYWORD") | |
|> List.map (fun line -> printfn "%s" line) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment