Open
Description
When I write a dataset to the same file twice (even with clobber=True
), I get an OS error:
import os
from netCDF4 import Dataset
try:
os.remove('example.nc')
except FileNotFoundError:
pass
mhw = Dataset('example.nc', mode='w', format='NETCDF4', clobber=True)
# No error if this is uncommented
# os.remove('example.nc')
mhw = Dataset('example.nc', mode='w', format='NETCDF4', clobber=True)
# Traceback (most recent call last):
# File "/opt/miniconda3/envs/extreme_env/lib/python3.11/site-packages/IPython/core/interactiveshell.py", line 3577, in run_code
# exec(code_obj, self.user_global_ns, self.user_ns)
# File "<ipython-input-16-d19a2f07cbe5>", line 14, in <module>
# mhw = Dataset('example.nc', mode='w', format='NETCDF4', clobber=True)
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Computer: Apple M3 Pro
Operating system: macOS version 14.6.1 (23G93)
Library versions (installed using conda):
% conda list | grep "netcdf"
h5netcdf 1.2.0 py311hca03da5_0
libnetcdf 4.8.1 h0fce390_4
netcdf4 1.6.2 py311h55fefbe_0
Permissions for the created file:
% ls - l
-rw-r--r--@ 1 alessandraquig staff 48 Jan 7 23:31 example.nc
The simple workaround is to delete the file first, but this seems bizarre given the point of clobber=True
is to allow me to overwrite an existing file.
Metadata
Metadata
Assignees
Labels
No labels