anncrystal

arcpy.setValue for Title casing

Discussion created by anncrystal on May 14, 2013
I am writing a function to change the case of records of multiple fields. But the field.title() method can't be implemented while using rows.setValue(). Could you please let me know where I am wrong? Please see the code below:

def ChangetoTitleCase(sourceTable, fieldNames):
      try:
        rows=arcpy.UpdateCursor(sourceTable)
        for row in rows:
          for fieldName in fieldNames:
            uField='"%s"' % fieldName
            row.setValue(uField, "uField.title()")
            rows.updateRow(row)
        del row, rows

      except Exception, e:
        import traceback, sys
        tb = sys.exc_info()[2]
        print "Line %i" % tb.tb_lineno
        print e.message


I am working with Python 2.6.5, Arcpy 10 and Win 7 64. Thanks in advance for any help!!!

Outcomes