fhs / NPZ.jl

A Julia package that provides support for reading and writing Numpy .npy and .npz files
Other
117 stars 16 forks source link

Support reading version 2 npys #31

Closed MRedies closed 5 years ago

MRedies commented 5 years ago

If I want to open an *.npy file saved in version 2 format (https://docs.scipy.org/doc/numpy-1.14.0/neps/npy-format.html) I get:

julia> den = npzread("bla.npy")
ERROR: unsupported NPZ version
Stacktrace:
 [1] error(::String) at ./error.jl:33
 [2] npzreadarray(::IOStream) at ~/.julia/packages/NPZ/TnTz7/src/NPZ.jl:209
 [3] npzread(::String) at ~/.julia/packages/NPZ/TnTz7/src/NPZ.jl:245
 [4] top-level scope at none:0

I belive adding support for v2 is quite easy: Line 211

hdrlen = readle(f, UInt16)

has to be replaced with an if-statement, that executes

hdrlen = readle(f, UInt32)

in case of v2.

MRedies commented 5 years ago

I tried to fix it in https://github.com/fhs/NPZ.jl/pull/32

fhs commented 5 years ago

Closing because fixed in #32.