# Accessing data on THREDDS OpenDAP via python (netcdf4 or xarray): Dealing with \_FillValue type mismatch error

**URL:** <https://discourse.oceanobservatories.org/t/accessing-data-on-thredds-opendap-via-python-netcdf4-or-xarray-dealing-with-fillvalue-type-mismatch-error/61>\
**Category:** Data Tools\
**Created:** [November 21, 2020, 12:02am UTC](https://discourse.oceanobservatories.org/t/accessing-data-on-thredds-opendap-via-python-netcdf4-or-xarray-dealing-with-fillvalue-type-mismatch-error/61 "2020-11-21T00:02:36Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![jaustin](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.oceanobservatories.org/jaustin/32/44_2.png) [@jaustin](https://discourse.oceanobservatories.org/u/jaustin)\
**Post date:** [November 21, 2020, 12:02am UTC](https://discourse.oceanobservatories.org/t/accessing-data-on-thredds-opendap-via-python-netcdf4-or-xarray-dealing-with-fillvalue-type-mismatch-error/61/1 "2020-11-21T00:02:36Z")

</div>

If you try to access OOI data via [http://thredds.dataexplorer.oceanobservatories.org/](http://thredds.dataexplorer.oceanobservatories.org/) OpenDAP, you may encounter the following error:

```
NetCDF: Not a valid data type or _FillValue type mismatch

```

This is due to a bug in THREDDS that will be fixed in a future release.

In the meantime, you can work around this issue simply by **appending `#fillmismatch` to the end of your url.**

Here’s a code snippet to illustrate this issue and the workaround:

```
import netCDF4 as nc
import xarray as xr

url = 'http://thredds.dataexplorer.oceanobservatories.org/thredds/dodsC/ooigoldcopy/public/CE02SHSM-RID27-03-CTDBPC000-recovered_host-ctdbp_cdef_dcl_instrument_recovered/deployment0010_CE02SHSM-RID27-03-CTDBPC000-recovered_host-ctdbp_cdef_dcl_instrument_recovered_20191022T140001.866000-20191122T204500.220000.nc'

# Running either of the commands below results in an error:
# OSError: [Errno -45] NetCDF: Not a valid data type or _FillValue type mismatch
xr.open_dataset(url)
nc.Dataset(url)

# Running either of these commands will open the file successfully
url_with_fillmismatch = f'{url}#fillmismatch'
ds = xr.open_dataset(url_with_fillmismatch)
print(ds)
with nc.Dataset(url_with_fillmismatch) as nc_ds:
    print(nc_ds)
```
