I am calling a list of names in from a text file and would like to use each of those to make new layers. I am running into an issue where I get "TypeError: cannot concatenate 'str' and 'list' objects" and am not sure how to get past this. I tried a couple of different where clauses without much luck.
*EDIT: Working code below. The issue was I am calling the file directly in the walk and the list fields. so when I am appending the path I needed to remove the filename from os.path.join(dirpath, filename).
import arcpy, os
from arcpy import env
#setup input varible
ws = r"M:/"
cl = r"/Admin_1.shp"
dem = r"M:/SRTM/dem"
#set output as a variable
out = r"M:/Elevation_Masks/Masks"
with open('M:/Elevation_Masks/test_space/elevCountries_Test.txt', 'r') as f:
cb = [line.strip() for line in f]
CNTRY_NAME_FIELD = 'CNTRY_NAME'
for dirpath, dirnames, filenames in arcpy.da.Walk(cl, datatype="FeatureClass", type="ALL"):
for filename in filenames:
if CNTRY_NAME in [f.name for f in arcpy.ListFields(cl)]:
for country_name in cb:
print "Country:", country_name
#setup where clause
where = '"%s" = \'%s\'' % (CNTRY_NAME, country_name)
arcpy.Select_analysis(os.path.join(dirpath), r"M:/Elevation_Masks/test_space/Country_Masks_Test/clipLayers_Test/clipLayers_Test.gdb/" + country_name + "_Boundary", where)