Skip to content

Instantly share code, notes, and snippets.

@noahmatisoff
Created June 22, 2015 19:25
Show Gist options
  • Save noahmatisoff/bc5444f8caf4e89894a3 to your computer and use it in GitHub Desktop.
Save noahmatisoff/bc5444f8caf4e89894a3 to your computer and use it in GitHub Desktop.
func GetGzip(path string) string {
println(path)
client := &http.Client{
Transport: &transport.Transport{
ReadTimeout: 10 * time.Second,
RequestTimeout: 15 * time.Second,
},
}
resp, err := client.Get(path)
if err != nil {
panic(err)
}
defer resp.Body.Close()
gzipReader, err := gzip.NewReader(resp.Body)
if err != nil {
panic("couldn't create gzip reader")
}
csvReader := csv.NewReader(gzipReader)
for {
record, err := csvReader.Read()
println(record)
if err == io.EOF {
break
} else if err != nil {
panic("Error reading csv record: " + err.Error())
}
// TODO do whatever you need with the record
println(record)
}
return "test"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment