I have two lists and I would like to find a way to select them based on names.
In list one I have a series of tif files:
list1=['LT50300281984137PAC00_sr_band1.tif',,'LT50300281984137PAC00_sr_band2.tif' 'LT50300281984137PAC00_sr_band3.tif','LT50300281994260XXX03_sr_band1.tif','LT50300281994260XXX03_sr_band2.tif','LT50300281994260XXX03_sr_band3.tif']in list two I have two files:
list2=[LT50300281984137PAC00_mask.tif,LT50300281994260XXX03_mask.tif]I want to exectue a process (which I won't ask how to do here) for files in list one which start with LT50300281984137PAC00 to the file in list 2 which starts the same way, and the same for the files which start with LT50300281994260XXX03.
I think it will go something like:
#select the files based on namesfor i in list1: if i[0:20] in list2:#this code executes the process I want ONLY if the naming matches for b in list1: arcpy.gp.ExtractByMask_sa(b,list2,outraster) else: print('Done')So basically if the file names in list 1 match those in list 2 I want to execute my process otherwise print done
أكثر...
In list one I have a series of tif files:
list1=['LT50300281984137PAC00_sr_band1.tif',,'LT50300281984137PAC00_sr_band2.tif' 'LT50300281984137PAC00_sr_band3.tif','LT50300281994260XXX03_sr_band1.tif','LT50300281994260XXX03_sr_band2.tif','LT50300281994260XXX03_sr_band3.tif']in list two I have two files:
list2=[LT50300281984137PAC00_mask.tif,LT50300281994260XXX03_mask.tif]I want to exectue a process (which I won't ask how to do here) for files in list one which start with LT50300281984137PAC00 to the file in list 2 which starts the same way, and the same for the files which start with LT50300281994260XXX03.
I think it will go something like:
#select the files based on namesfor i in list1: if i[0:20] in list2:#this code executes the process I want ONLY if the naming matches for b in list1: arcpy.gp.ExtractByMask_sa(b,list2,outraster) else: print('Done')So basically if the file names in list 1 match those in list 2 I want to execute my process otherwise print done
أكثر...