I am trying to write a second update cursor within one script. This requires a LIKE condition to look up a value within the same layer to identify rows to update the field within that layer (first update cursor looks up a second table and is working successfully). When I try to run the query it is throwing a syntax error and highlighting LIKE.
See my initial question about Writing python script to select attributes not in growing table with over 4000 values?.
Here is the portion of script in causing the issue:
with arcpy.da.UpdateCursor("in_memory/headphotos",[field2,'Located']) as UCur1:
for URow1 in UCur1:
if URow1[0].lower() LIKE '%reserve%':
URow1[1] = 1
Here is my full script:
import os, sys, arcpy
arcpy.env.workspace = (directory location)
jpgList = arcpy.ListRasters('*','JPG')
photos = ([s.lower().strip('.jpg') for s in jpgList ])
arcpy.CopyFeatures_management(feature class location,r"in_memory/headphotos")
arcpy.AddField_management(r"in_memory/headphotos",'Located','SHORT')
with arcpy.da.UpdateCursor("in_memory/headphotos",['ce_id','Located']) as UCur:
for URow in UCur:
if URow[0].lower() in photos:
URow[1] = 1
else:
URow[1] = 0
UCur.updateRow(URow)
with arcpy.da.UpdateCursor("in_memory/headphotos",[field2,'Located']) as UCur1:
for URow1 in UCur1:
if URow1[0].lower() LIKE '%reserve%':
URow1[1] = 1
arcpy.MakeFeatureLayer_management("in_memory/headphotos","tmp_layer",'Located = 0')
arcpy.CopyFeatures_management("tmp_layer",new layer)