import arcgisscripting gp = arcgisscripting.create(9.3) fc = r'C:\bla\blabbla.dbf' fieldlist = gp.ListFields(fc, "AGE*") pylist = [] for field in fieldlist: fn = field.Name fn_format = "!" + fn + "! " pylist.append(fn_format) CalcList = " + ".join(pylist) Exp = '"' + CalcList + '"' gp.CalculateField_management(fc, "Tot", Exp) print Exp
fields=gp.FieldsList(featureclass) newlist=[] for field in fields: if re.match('^AGE', field)<>None: newlist.append(re.match('^AGE', field)) while row: value=0 for field in newlist: value+=row.getvalue(field) row.Setvalue(newfield, value) row.UpdateRow() row=cursor.Next()
From HELP: object.SearchCursor(InputValue As String, {WhereClause} As String, {SpatialReference} As Object, {FieldList} As String, {SortFields} As String) As Object
import arcgisscripting gp = arcgisscripting.create( 9.3 ) gp.SetProduct( 'ArcInfo' ) gp.Workspace = r'C:\Users\wannaz\Documents\Projects\ArcGIS General\Scratch.gdb' gp.OverwriteOutput = 1 myFeatureClass = 'polygons' fields_pyList = gp.ListFields( myFeatureClass, "OBS*" ) print type( fields_pyList ) print type( fields_pyList[1] ) fields_str = '' for field_gpObj in fields_pyList : print "Field :", field_gpObj.Name if fields_str != '' : fields_str += '; ' fields_str += field_gpObj.Name print fields_str rows = gp.SearchCursor( myFeatureClass, "", "", fields_str ) row = rows.Next() l = 1 while row : print "\nLine ", l, ":" for field_gpObj in fields_pyList : print field_gpObj.Name, "=", row.GetValue(field_gpObj.Name), ", ", row = rows.Next() l += 1
import arcgisscripting gp = arcgisscripting.create(9.3) fc = r"C:\Temp\dataset" fieldlist = gp.ListFields(fc, "OBS*") rows = gp.Searchcursor(fc, "", "", fieldlist)
My original idea was to create a fieldlist using ListFields with a the wildcard AGE*, then open up a searchcursor where I use the fieldlist to catch my relevant fields and finally for each row to summarize the values in the fieldlist and send it to the new field with an insertcursor. Something tells me that�??s not best way to approach this�?�
Signed in members can post, follow updates, and more. New here? Register a free account.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.