Search code examples
pythonnetcdf

Programmatically list all variables of a NetCDF file using netCDF4 and Python


How do I programmatically list all variables of a NetCDF file that I have read in using netCDF4 and Python?

import netCDF4
dset = netCDF4.Dataset('test.nc')

Solution

  • From the documentation, here, it looks like it would just be:

    import netCDF4
    dset = netCDF4.Dataset('test.nc')
    dset.variables