I'm trying to utilize the extractSubdataset_management tool on a large set of GRB files. Each GRB file has a different number of subdatasets.
Is there any way to execute this tool on all subdatasets contained in each GRB rather than specifying the number of bands?
code so far as follows:
import os import arcpy path = "C:/CHRIS/testfolder/testgrib" gribs = os.listdir(path) grib = gribs os.chdir(path) print os.getcwd() grb = arcpy.env.workspace = "C:/CHRIS/testfolder/testgrib" for item in gribs: print item os.mkdir(os.path.join(path, item + '.subdata')) folder = path + "/" + item + ".subdata" for i in range(0,115): numb=str(i) try: arcpy.ExtractSubDataset_management(item, folder + "/test" + numb + ".tif", numb) except Exception as e: print e break
so inside the "testgrib" folder are 2 .grb files. One of the files has 112 subdatasets, while the second file has 114 subdatasets. If I specify my range from 0-112, I get an output of 0-112, but in doing so it will omit the remaining 2 subdatasets from the second .grb file.