0

This question already has an answer here:

When using the title method, can it only be used on a string or can it run through an entire field and update Names to proper case in a table?

str.title()

I have tried the following and it did not work;

arcpy.title(table,'Field')

marked as duplicate by PolyGeo arcpy Mar 28 '17 at 22:42

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • The only difference between this question and the duplicate seems to be that it uses title rather than upper method. – PolyGeo Mar 28 '17 at 22:43
2

It can be used on table field/values that are data type string/text. Use either Field Calculator, Calculate Field, or arcpy da update cursor.

eg. Field Calculator and Calculate Field:

!myField!.title()

eg. arcpy da update cursor:

with arcpy.da.UpdateCursor(fc, 'myFieldName') as cursor:
  for row in cursor:
    if row[0]:  # check for value
      row[0] = row[0].title()
      cursor.updateRow(row)
  • When testing this script I get the following error row[0] = row[0].title() AttributeError: 'NoneType' object has no attribute 'title' – Purplepeopleeater Mar 28 '17 at 21:14
  • @winscott68, I'm guessing it is because it is trying to perform the .title() method on a NULL value which is not a string. I've updated my answer to check for this. – artwork21 Mar 29 '17 at 12:27

Not the answer you're looking for? Browse other questions tagged or ask your own question.