Source

go-play / zfile.go

Full commit
package main

import (
	"archive/zip"
	"encoding/csv"
	"fmt"
	"io"
	"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 == io.EOF {
			break
		}
		value, err := strconv.ParseUint(record[1], 10, 64)
		if err != nil {
			continue
		}
		num_impressions += value
	}

	fmt.Println(num_impressions)

}