Skip to content

Instantly share code, notes, and snippets.

@Eastonium
Created October 28, 2014 19:46
Show Gist options
  • Save Eastonium/91f0d1269c2ce63d7e77 to your computer and use it in GitHub Desktop.
Save Eastonium/91f0d1269c2ce63d7e77 to your computer and use it in GitHub Desktop.
from netCDF4 import Dataset
import glob
import time
#This is a simple script to add to the end of the history attribute in netCDF files
for f in glob.glob("/data/home/gervais/prod/jobs/0431/collection/fkb/fkbmwrhfM1.b1/*.cdf"): #Path to data
ncfile = Dataset(f, "r+");
ncfile.history +=" Modified by user <user> on machine <machine> at "+time.strftime("%d-%b-%Y,%H:%M:%S")+" using scripts/RID0431/mod.py $";#The last bit about scripts is optional
print ncfile.history;
ncfile.close();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment