Programmatically list all variables of a NetCDF file using netCDF4 and Python
11,018
Solution 1
From the documentation, here, it looks like it would just be:
import netCDF4
dset = netCDF4.Dataset('test.nc')
dset.variables
Solution 2
dset.variables.keys()
would provide you with a list of the variables.
Solution 3
To list all variable names as strings just do:
list(dset.variables.keys())
or simple
list(dset.variables)
Author by
user308827
Updated on July 09, 2022Comments
-
user308827 almost 2 years
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')