Skip to content

Instantly share code, notes, and snippets.

@cipepser
Created March 31, 2018 04:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cipepser/82757c3b8676b53ccfd7cdcde06b2349 to your computer and use it in GitHub Desktop.
Save cipepser/82757c3b8676b53ccfd7cdcde06b2349 to your computer and use it in GitHub Desktop.
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