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']
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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.