Created
March 31, 2018 04:02
-
-
Save cipepser/82757c3b8676b53ccfd7cdcde06b2349 to your computer and use it in GitHub Desktop.
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
package main | |
import ( | |
"bufio" | |
"io" | |
"os" | |
"strings" | |
) | |
func main() { | |
fr, err := os.Open("../data/questions-words.txt") | |
defer fr.Close() | |
if err != nil { | |
panic(err) | |
} | |
r := bufio.NewReaderSize(fr, 4096) | |
fw, err := os.Create("../data/q91.out.txt") | |
defer fw.Close() | |
if err != nil { | |
panic(err) | |
} | |
w := bufio.NewWriterSize(fw, 4096) | |
defer w.Flush() | |
flg := false | |
delimiter := ": " | |
for { | |
l, _, err := r.ReadLine() | |
if err == io.EOF { | |
break | |
} | |
if err != nil { | |
panic(err) | |
} | |
if strings.Contains(string(l), delimiter) { | |
if flg { | |
break | |
} | |
if strings.Contains(string(l), "family") { | |
flg = true | |
} | |
} | |
if flg { | |
w.Write(l) | |
w.Write([]byte("\n")) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment