home / github / issue_comments

Menu
  • GraphQL API
  • Search all tables

issue_comments: 605618860

This data as json

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/3593#issuecomment-605618860 https://api.github.com/repos/pydata/xarray/issues/3593 605618860 MDEyOklzc3VlQ29tbWVudDYwNTYxODg2MA== 14808389 2020-03-29T11:02:42Z 2020-03-29T11:02:42Z MEMBER

sorry for the late reply, @lukaskroe.

Not sure why you can make it fail after the first move but I think the general issue happens because you didn't close the opened file: ```python In [29]: path = "test.nc" ...:
...: a = np.linspace(0, 1, 100) ...: x = np.arange(100) ...: xr.Dataset({"a": ("x", a)}, coords={"x": x}).to_netcdf(path) ...:
...: ds = xr.open_dataset(path) ...: print(ds) ...:
...: os.rename(path, "test2.nc") ...:
...: ds = xr.open_dataset(path) ...: print(ds) <xarray.Dataset> Dimensions: (x: 100) Coordinates: * x (x) int64 0 1 2 3 4 5 6 7 8 9 10 ... 90 91 92 93 94 95 96 97 98 99 Data variables: a (x) float64 ... <xarray.Dataset> Dimensions: (x: 100) Coordinates: * x (x) int64 0 1 2 3 4 5 6 7 8 9 10 ... 90 91 92 93 94 95 96 97 98 99 Data variables: a (x) float64 ...

In [30]: path = "test.nc" ...:
...: a = np.linspace(0, 1, 100) ...: x = np.arange(100) ...: xr.Dataset({"a": ("x", a)}, coords={"x": x}).to_netcdf(path) ...:
...: ds = xr.open_dataset(path) ...: print(ds) ...: ds.close() ...: os.rename(path, "test2.nc") ...:
...: ds = xr.open_dataset(path) ...: print(ds) <xarray.Dataset> Dimensions: (x: 100) Coordinates: * x (x) int64 0 1 2 3 4 5 6 7 8 9 10 ... 90 91 92 93 94 95 96 97 98 99 Data variables: a (x) float64 ...


KeyError Traceback (most recent call last) ... KeyError: [<class 'netCDF4._netCDF4.Dataset'>, ('.../test.nc',), 'r', (('clobber', True), ('diskless', False), ('format', 'NETCDF4'), ('persist', False))]

During handling of the above exception, another exception occurred:

FileNotFoundError Traceback (most recent call last) ... FileNotFoundError: [Errno 2] No such file or directory: b'.../test.nc' ```

To be absolutely sure you close it use a context manager: python with xr.open_dataset(path) as ds: ...

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  532647948
Powered by Datasette · Queries took 0.878ms · About: xarray-datasette