Example: On the basis of the table which is not defined by the number of columns and rows, you need to evaluate expressions as shown, using the arcpy.SearchCursor ....

enter image description here

First, create a list of fields, using the arcpy.ListFields Then, using SearchCursor needs to calculate the defined an expression, for each column separately ...

I should be to existing code insert defined an expression....

 values = [] # store the sum values here.
 fields = arcpy.ListFields(fc, "*")

 # get the OID/FID field name to skip
 desc = arcpy.Describe(fc)
 if desc.hasOID:
     OIDname = desc.OIDFieldName.upper()
     OIDname = ""

 for field in fields:
     if field.name.upper() != OIDname: # skip the OID/FID field.
         if field.type in ("Double", "Integer", "Single"):
             # sum each suitable field, but not the NULL ones - they would be bad
             with arcpy.da.SearchCursor(fc,field.name,field.name + " is not NULL") as sCur:
                 thisValue = 0
                 for row in sCur:
                     thisValue += row[0]
                 values.append(thisValue) # this will be the inserted row

 with arcpy.da.InsertCursor(fc, fieldNameList) as cur:

@Michael Miles-Stimson provided the preceding code.

Instead of the sum of the "thisValue" to create a new expression?

closed as off-topic by Erica, Vince, Mapperz Mar 11 '15 at 14:59

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Questions about software development are off-topic here unless they relate directly to Geographical Information Systems, but they can be asked on Stack Overflow." – Erica, Vince, Mapperz
If this question can be reworded to fit the rules in the help center, please edit the question.

  • The easiest way to do this is to use the right tool for the purpose – Vince Mar 11 '15 at 11:46
  • 1
    Could you please clarify this question? As it stands, this is difficult to interpret. It would be helpful to define your variables too. – Aaron Mar 11 '15 at 14:38
  • The more complex math that you want to do isn't really GIS related, it's just python (manipulating/storing variables) – Erica Mar 11 '15 at 16:39
  • im using arcpy for calculation spatial index. Is't GIS? – kamfulebu Mar 11 '15 at 16:43
  • 1
    Especially when you get into python scripting, there are a lot of issues which could be better answered by Python experts than by GIS experts (even though there's some overlap) -- so really StackOverflow is a better fit and more likely to get you the solution you need :) – Erica Mar 12 '15 at 12:58

Browse other questions tagged or ask your own question.