Zarr.jl icon indicating copy to clipboard operation
Zarr.jl copied to clipboard

adding and editing attributes to an existing zarr array

Open Alexander-Barth opened this issue 1 year ago • 1 comments

I am wondering if it is possible to add or edit attributes of a zarr array after it has been created.

Here is a naive attempt to do so:

using Zarr 
fname = tempname()
z1 = zcreate(Int, 1000,1000,path = fname,chunks=(100, 100),attrs = Dict(
    "bar" => "foo",
))
z2 = zopen(fname,"w")
z2.attrs["bar"]  = 42
# need a zclose?

z2 = zopen(fname,"r")
z2.attrs["bar"]
# still "foo"

Maybe we would need a zclose that synchronizes z2.attrs with the json file .zattrs.

I am using Zarr v0.9.1.

Alexander-Barth avatar Nov 24 '23 11:11 Alexander-Barth

Maybe functions like the put, update, and refresh methods in https://zarr.readthedocs.io/en/stable/api/attrs.html would be useful.

nhz2 avatar Nov 26 '23 20:11 nhz2