With the python netcdf4 library I want to write a test dataset for my netcdf4 read script. However, I am not able to generate the desired output.
This is currently my write script:
# write file
varlist = ['ABC123', 'DEF456', 'GHI789']
varlist = np.array([[i for i in k] for k in varlist], dtype='S1')
with Dataset(indexfile, 'w', format='NETCDF4') as file:
file.createDimension('vars', [3,6])
vars_list = file.createVariable('vars', 'S1', (u'vars',))
vars_list[:] = varlist
But this returns a TypeError
:
TypeError: an integer is required
How should I change my input or write a script to get the desired result?