listrasters wildcard multiple characters

690
2
08-23-2011 02:46 AM
AlexanderHohl
New Contributor II
Dear all,
I am trying to list a group of rasters in a file geodatabase. The rasters are named ending with numbers from 1-12 (eg. precip_1, precip_2, ...). I want to have a list of those rasters that end with the numbers 4-9.
How can I achieve this? I thought of using the wildcard in the listrasters statement but I can't figure out how to search for multiple characters.
here's the statement:

Rasters = gp.ListRasters(?)

Any advice is very much appreciated.
Thanks,
LionelMessi
Tags (2)
0 Kudos
2 Replies
JakeSkinner
Esri Esteemed Contributor
You could do this using a 'while' loop.  Ex:

x = 4

while x < 10:
    lstRasters = gp.ListRasters("*" + str(x))
    for raster in lstRasters:
        print raster
    x += 1
AlexanderHohl
New Contributor II
You could do this using a 'while' loop.  Ex:

x = 4

while x < 10:
    lstRasters = gp.ListRasters("*" + str(x))
    for raster in lstRasters:
        print raster
    x += 1


This works excellent. Thanks a lot JSkinn.