iteration question - replace string

Discussion created by joelzao on Feb 25, 2014
Latest reply on Feb 25, 2014 by joelzao
I was wondering if somebody might be able to shed some light on what I'm doing wrong here. I have a file geodatabase with some tables in it. I want the script to iterate through each of the tables, look in one specific field ("PHOTO1"), and then look at the existing URL path that is there in the field, and do a replace on the string. Where it sees "\Photo\", it will change it to "_Patrol\Photo\".

It seems like what I have should work, yet I get an error that says "TypeError: 'NoneType' object is not iterable". Any ideas?

import arcpy
arcpy.env.workspace = "C:\Users\jp8439\Desktop\temp.gdb"
tableList = arcpy.ListTables()                                        #list the tables in the geodatabase
for table in tableList:                                                    #iterate the tables
    cursor = arcpy.UpdateCursor(table)                             #place update cursor in the first table
    for row in cursor:          
        str = row.getValue("PHOTO1")                                  #get string value in PHOTO1 field
        rep = str.replace("\\Photos\\", "_Patrol\\Photos\\")       #variable to replace "photos" with "_patrol\photos"
        row.setValue("PHOTO1", rep)                                   # do the replace
del cursor, row