Setting Up a netCDF File for Appending

Question

How do you open/set up an existing netCDF file so that you can append data to it?

Answer

When you open/set up the netCDF file (for instance, using the constructor for the NetCDFFile class in module Scientific.IO.NetCDF), you specify 'a' instead of 'w', which tells Python you will append to the existing file. Then, instead of specifying the length of the unlimited axis (usually the time axis), set the length to None.

Remember you can only have one unlimited axis at a time.

Note: Thanks to Helene Brogniez for the tip!

Return to the Tips and Examples index page.

Valid HTML 4.01! Valid CSS! Updated: July 18, 2005 by Johnny Lin <email address>. License.