diff options
author | Martin Czygan <martin.czygan@gmail.com> | 2021-09-28 13:39:19 +0200 |
---|---|---|
committer | Martin Czygan <martin.czygan@gmail.com> | 2021-09-28 13:39:19 +0200 |
commit | 4d109a3fd5940ef27ed3e68fdebf0ccd3f234c28 (patch) | |
tree | b28505d2a5bee9b60477260edb2dc664510b4c93 /extra/mag/memkey.go | |
parent | 3af89868253a45f4e3fe912443276b31b7c72521 (diff) | |
download | refcat-4d109a3fd5940ef27ed3e68fdebf0ccd3f234c28.tar.gz refcat-4d109a3fd5940ef27ed3e68fdebf0ccd3f234c28.zip |
mag: notes on doi-to-doi refs
Diffstat (limited to 'extra/mag/memkey.go')
-rw-r--r-- | extra/mag/memkey.go | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/extra/mag/memkey.go b/extra/mag/memkey.go new file mode 100644 index 0000000..b2e4b42 --- /dev/null +++ b/extra/mag/memkey.go @@ -0,0 +1,45 @@ +package main + +import ( + "bufio" + "fmt" + "io" + "log" + "os" + "strconv" + "strings" +) + +func main() { + var ( + cache = make(map[int]string) + br = bufio.NewReader(os.Stdin) + i int + ) + for { + line, err := br.ReadString('\n') + if err == io.EOF { + break + } + if err != nil { + log.Fatal(err) + } + fields := strings.Split(line, "\t") + if len(fields) < 2 { + continue + } + a, b := strings.TrimSpace(fields[0]), strings.TrimSpace(fields[1]) + id, err := strconv.Atoi(a) + if err != nil { + log.Println("skipping invalid id: %s", line) + continue + } + cache[id] = b + i++ + if i%1000000 == 0 { + log.Printf("%d", i) + } + } + log.Println("press enter to quit") + fmt.Scanln() +} |