I have a shapefile with an attribute table similar to the one below.
NAME
| CAT | DOG |
---|
***John | black | black |
***Pat | tabby | <Null> |
Joe | <Null> | white |
First, I want to search for any rows where 'NAME' starts with '***'. Then, from that selection I want to print out data if the 'DOG' column is not <Null>.
Using the table above the output should look like this.
C:\MyDocs\Python>python Animal.py
***John
black
C:\MyDocs\Python>
Here is my code so far
def findAnimal(shapefilePath):
fields = ('NAME','CAT','DOG')
cursor = arcpy.da.UpdateCursor(sp,fields)
for row in cursor:
nameStr = row[0]
if nameStr[0:3] == "***":
if row[2] != None:
print row[0]
print row[2]
cursor.updateRow(row)
This is what my code is currently printing out.
C:\MyDocs\Python>python Animal.py
***John
black
***Pat
C:\MyDocs\Python>
There is blank row after '***Pat' ,so it looks like it is printing out the <Null> value.
It appears that Line 07 in my code is not working.