Open ascetic168 opened 5 years ago
how can i help with adding string support?
seems non-trivial as numpy's dtype includes the length of the string (e.g. U18
for 18 characters of unicode) and so the dictionary used by NPZ.jl to convert to a julia type would have to be reworked. ugh.
in the meantime, reading what is supported helps my use case:
diff --git a/src/NPZ.jl b/src/NPZ.jl
index 39ccbc1..6babc7e 100644
--- a/src/NPZ.jl
+++ b/src/NPZ.jl
@@ -262,7 +262,11 @@ function npzread(dir::ZipFile.Reader)
if endswith(name, ".npy")
name = name[1:end-4]
end
- vars[name] = npzreadarray(f)
+ try
+ vars[name] = npzreadarray(f)
+ catch
+ @warn string("unable to read variable ",name)
+ end
end
vars
end
if you like, i could work this up to include proper exceptions and submit a PR.
In Numpy, string array to npz file is legal. "np.savez_compressed" in Python works fine. ex: something like ["name1" "name2" "name3"]
So far, NPZ.jl can not read/write such kind of data. Would you like to add the support?