html_url,issue_url,id,node_id,user,created_at,updated_at,author_association,body,reactions,performed_via_github_app,issue
https://github.com/pydata/xarray/issues/6456#issuecomment-1098574761,https://api.github.com/repos/pydata/xarray/issues/6456,1098574761,IC_kwDOAMm_X85Beuup,3698640,2022-04-13T23:34:16Z,2022-04-13T23:34:48Z,CONTRIBUTOR,"> In the example it's saving every iteration, but in my actual code it's much less frequent
when I said ""you're overwriting the file every iteration"" I meant to put the emphasis on _overwiting_. by using `mode='w'` instead of `mode='a'` you're telling zarr to delete the file if it exists and the re-create it every time `to_zarr` is executed.
See the docs on [`xr.Dataset.to_zarr`](https://xarray.pydata.org/en/stable/generated/xarray.Dataset.to_zarr.html):
> **mode** (`{""w"", ""w-"", ""a"", ""r+"", None}`, *optional*) – Persistence mode: “w” means create (overwrite if exists); “w-” means create (fail if exists); “a” means override existing variables (create if does not exist); “r+” means modify existing array values only (raise an error if any metadata or shapes would change). The default mode is “a” if `append_dim` is set. Otherwise, it is “r+” if `region` is set and `w-` otherwise.
This interpretation of mode is consistent across all of python - see the docs for [python builtins: open](https://docs.python.org/3/library/functions.html#open)
So I think changing your writes to `ds3.to_zarr('zarr_bug.zarr', mode='a')` as Max suggested will get you a good part of the way there :)","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,1197117301
https://github.com/pydata/xarray/issues/6456#issuecomment-1094411214,https://api.github.com/repos/pydata/xarray/issues/6456,1094411214,IC_kwDOAMm_X85BO2PO,3698640,2022-04-10T23:40:49Z,2022-04-10T23:40:49Z,CONTRIBUTOR,"@tbloch1 following up on Max's suggestion - it looks like you might be overwriting the file with every iteration. See the docs on [ds.to_zarr](https://xarray.pydata.org/en/stable/generated/xarray.Dataset.to_zarr.html) - `mode='w'` will overwrite the file while `mode='a'` will append. That said, you still would need your indices to not overlap. How are you distinguishing between the files? is each one a different point in time?
To me, this doesn't seem likely to be a bug, but is more of a usage question. Have you tried asking on stackoverflow with the xarray tag?
","{""total_count"": 1, ""+1"": 1, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,1197117301