Hello. I am very new to Python and scripting in general, and would appreciate any assistance with my following problem.
I've created an extremely simple Python script that strips away unnecessary characters from fields in a shapefile. The script works within PythonWin and returns no errors. However, when I make a script tool in ArcMap and try to deploy the same function, it crashes ArcMap. Sometimes the data is actually updated, other times no. But every time I try the script tool, ArcMap becomes unresponsive, jumps to 100% of CPU use, and has to be shut down from within Task Manager. Below is my working script. Any comments or suggestions would be welcome.
Thank you for your time.
import arcpy
featureClass = arcpy.GetParameterAsText(0)
rows = arcpy.UpdateCursor(featureClass)
row = rows.next()
while row:
subtypeValue = row.SUBTYPE
subtypeValueIndex = subtypeValue.split(" ")
row.SUBTYPE = subtypeValueIndex[0]
materialValue = row.STRMAT
strmatValueIndex = materialValue.split("-")
row.STRMAT = strmatValueIndex[0]
photoynValue = row.PHOTOYN
photoynValueIndex = photoynValue.split("-")
row.PHOTOYN = photoynValueIndex[0]
conditionValue = row.CONDITION
conditionValueIndex = conditionValue.split("-")
row.CONDITION = conditionValueIndex[0]
clidmatValue = row.CLIDMAT
clidmatValueIndex = clidmatValue.split("-")
row.CLIDMAT = clidmatValueIndex[0]
accesstypeValue = row.ACCESSTYPE
accesstypeValueIndex = accesstypeValue.split("-")
row.ACCESSTYPE = accesstypeValueIndex[0]
groundtypeValue = row.GROUNDTYPE
groundtypeValueIndex = groundtypeValue.split("-")
row.GROUNDTYPE = groundtypeValueIndex[0]
stepsValue = row.STEPS
stepsValueIndex = stepsValue.split("-")
row.STEPS = stepsValueIndex[0]
skimmerValue = row.SKIMMER
skimmerValueIndex = skimmerValue.split("-")
row.SKIMMER = skimmerValueIndex[0]
lcyclestatValue = row.LCYCLESTAT
lcyclestatValueIndex = lcyclestatValue.split("-")
row.LCYCLESTAT = lcyclestatValueIndex[0]
collectbyValue = row.COLLECTBY
collectbyValueIndex = collectbyValue.split("-")
row.COLLECTBY = collectbyValueIndex[0]
datasourceValue = row.DATASOURCE
datasourceValueIndex = datasourceValue.split("-")
row.DATASOURCE = datasourceValueIndex[0]
erosionValue = row.EROSION
erosionValueIndex = erosionValue.split("-")
row.EROSION = erosionValueIndex[0]
rows.updateRow(row)
row = rows.next()
del row, rows