1. Miki Tebeka
  2. go-play

Commits

Miki Tebeka  committed 0945367

zfile

  • Participants
  • Parent commits 39b59a7
  • Branches default

Comments (0)

Files changed (1)

File zfile.go

View file
+package main
+
+import (
+	"archive/zip"
+	"csv"
+	"fmt"
+	"os"
+	"strconv"
+)
+
+func main() {
+	z, err := zip.OpenReader("acamp.zip")
+
+	if err != nil {
+		fmt.Println("error: can't open")
+		os.Exit(1)
+	}
+	defer z.Close()
+
+	fdm, err := z.File[0].Open()
+	defer fdm.Close()
+	reader := csv.NewReader(fdm)
+
+	var num_impressions uint64
+	for {
+		record, err := reader.Read()
+		if err == os.EOF {
+			break
+		}
+		value, err := strconv.Atoui64(record[1])
+		if err != nil {
+			continue
+		}
+		num_impressions += value
+	}
+
+	fmt.Println(num_impressions)
+
+}