Reputation: 5295
I have filenames listed from arcpy (arcmap) as follows in 'inner'.
inner = [u'aet1941jan.asc', u'aet2004jun.asc', u'aet1981nov.asc', u'aet1985feb.asc', u'aet1974sep.asc', u'aet1900sep.asc', u'aet1994apr.asc', u'aet1970nov.asc']
I am looking for a way to extract only the rasters that are post-1990. How can I build a logical expression that remove all elements all the old rasters from the list?
Such that the ouput would be a list:
out = [u'aet2004jun.asc', u'aet1994apr.asc']
Upvotes: 1
Views: 921
Reputation: 1121834
A list comprehension is easiest:
out = [v for v in inputlist if int(v[3:7]) >= 1990]
Note that you cannot name a variable in
; I used inputlist
instead.
The above assumes characters 3 through to 6 are always the year in your values.
Upvotes: 7