kshedden / gonpy

Read and write Numpy binary files (.npy files) in Golang

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Unable to generate npz file

clyang opened this issue · comments

Following the instruction on README but no gzipped file is generated.

Sample code:

package main

import (
    "os"
    "compress/gzip"
    "github.com/kshedden/gonpy"
)

func main() {
    data := []float64{0, 1, 2, 3, 4, 5, 6, 7}

    f, _ := os.Open("data.npy.gz")
    g := gzip.NewWriter(f)
    w, _ := gonpy.WriterFromStream(g)
    w.Shape = []int{4, 2}
    _ = w.WriteFloat64(data)
    f.Close()
}

There was an error in the README. Open should have been Create. It is fixed now. Thanks for the report.