maxswiatkowski

Capitalizing Fields

Discussion created by maxswiatkowski on Jul 26, 2011
Latest reply on Jul 26, 2011 by dhoneycutt-esristaff
Hi Everyone:

I'm hoping to get some assistance from minds that are better than my own.
I'm new to python but I'm trying to cobble together a script that will let me capitalize first letters in certain fields of shapefiles that I have.

Here is my code:

import sys, string, os, arcgisscripting
gp = arcgisscripting.create(9.3)
gp.AddToolbox("C:/Program Files/ArcGIS/ArcToolbox/Toolboxes/Data Management Tools.tbx")
gp.Workspace = "C:/Max/Bathymetry_Cleanup/vector/zone17"

gp.OverWriteOutput = True

vectorlist = gp.ListFeatureClasses ("17*", "all")

for vector in vectorlist:
    updateRows = gp.UpdateCursor(vector)
    updateRow = updateRows.Next()
    while updateRow:
           newString = ""
           for word  in updateRow.Units.split(" "):
              newString = word.capitalize() + " " + newString
           updateRow.Units = newString[:-1]
           updateRows.updaterow(updateRow)
    updateRow = updateRows.Next()
    del updateRow
    del updateRows
   
    updateRows = gp.UpdateCursor(vector)
    updateRow = updateRows.Next()
    while updateRow:
       newString = ""
       for word  in updateRow.Units.split(" "):
          newString = word.capitalize() + " " + newString
       updateRow.Srvy_Meth = newString[:-1]
       updateRows.updaterow(updateRow)
    updateRow = updateRows.Next()
    del updateRow
    del updateRows
   
    updateRows = gp.UpdateCursor(vector) 
    updateRow = updateRows.Next()
    while updateRow:
        newString = ""
        for word  in updateRow.Creat_Meth.split(" "):
            newString = word.capitalize() + " " + newString
        updateRow.Creat_Meth = newString[:-1]
        updateRows.updaterow(updateRow)
    updateRow = updateRows.Next()
    del updateRow
    del updateRows
   
    gp.CalculateField_management(vector, "Accuracy", "str(!Accuracy!).upper()", "PYTHON", "")

When I try to run this process, I get an error reading:

Traceback (most recent call last):
  File "C:\Max\python.py", line 17, in <module>
    updateRows = gp.UpdateCursor(vector)
RuntimeError: ERROR 999999: Error executing function.
General function failure

I also tried running it with quotation marks around vector but that gives me the following error:

Traceback (most recent call last):
  File "C:\Max\python.py", line 17, in <module>
    updateRows = gp.UpdateCursor("vector")
RuntimeError: ERROR 999999: Error executing function.
A locator with this name does not exist.

Thanks for any help,

Max

Outcomes