Skip to content

Instantly share code, notes, and snippets.

@shuuji3
Created June 6, 2020 21:10
Show Gist options
  • Save shuuji3/ddc7c75649f1ae012ed8ca35c5e15221 to your computer and use it in GitHub Desktop.
Save shuuji3/ddc7c75649f1ae012ed8ca35c5e15221 to your computer and use it in GitHub Desktop.
a disposable script to process a temporary text file
package main
import (
"bufio"
"fmt"
"log"
"os"
"strings"
)
func main() {
f, err := os.Open("chara-counts.txt")
defer f.Close()
if err != nil {
log.Fatal(err)
}
rd := bufio.NewReader(f)
for {
line, err := rd.ReadString('\n')
if err != nil {
log.Fatal(err)
}
cols := strings.Split(strings.Trim(line, "\n"), " ")
charNum := cols[4]
studentID := strings.Split(cols[5], "@")[0]
fmt.Println(charNum, studentID) // dirty
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment