can somebody tell me how can i count character in a field either using field calculator or cursor.
i tried the below code :
import arcpy inputFeatureClass = arcpy.GetParameterAsText(0) InputField = arcpy.GetParameterAsText(1) expression = "len(!" + InputField + "!)" arcpy.AddField_management(inputFeatureClass,"CountChr","SHORT") arcpy.CalculateField_management(inputFeatureClass,"CountChr",expression,"PYTHON_9.3") but result is null.
i tried cursor :
import arcpy #taking input from user inputFeatureClass = arcpy.GetParameterAsText(0) InputField = arcpy.GetParameterAsText(1) arcpy.AddField_management(inputFeatureClass,"CountChr","SHORT") cursor = arcpy.da.UpdateCursor (inputFeatureClass, [InputField, "CountChr"]) for row in cursor: row[1] = len(row[0]) cursor.updateRow(row) del cursor but result is again null
can somebody tell me why this is happening ?
أكثر...
i tried the below code :
import arcpy inputFeatureClass = arcpy.GetParameterAsText(0) InputField = arcpy.GetParameterAsText(1) expression = "len(!" + InputField + "!)" arcpy.AddField_management(inputFeatureClass,"CountChr","SHORT") arcpy.CalculateField_management(inputFeatureClass,"CountChr",expression,"PYTHON_9.3") but result is null.
i tried cursor :
import arcpy #taking input from user inputFeatureClass = arcpy.GetParameterAsText(0) InputField = arcpy.GetParameterAsText(1) arcpy.AddField_management(inputFeatureClass,"CountChr","SHORT") cursor = arcpy.da.UpdateCursor (inputFeatureClass, [InputField, "CountChr"]) for row in cursor: row[1] = len(row[0]) cursor.updateRow(row) del cursor but result is again null
can somebody tell me why this is happening ?
أكثر...