Quantcast
Channel: Question and Answer » arcpy
Viewing all articles
Browse latest Browse all 767

Inserting row into table and then updating it in sum of each column using ArcPy?

$
0
0

My problem is the following:

  • I have a table with an unknown number of columns (n)

  • Use arcpy.ListFields create a list of columns and generates Field name list

  • Then, using arcpy.da.InsertCursor create a new row at the end of the table …

for example

  fieldNameList = []     
  fields = arcpy.ListFields(fc, "*")

  for field in fields:
     if field.type in ("Double", "Integer", "Single"): 
        fieldNameList.append(field.name) 

 cur = arcpy.da.InsertCursor(fc, fieldNameList)
 for x in xrange(-1, 0):
     cur.insertRow((SUM_FIELD1, SUM_FIELD2...SUM_FIELD n ))       ?????????!!!!
 del cur

I do not know how to calculate the sum for each column and then the result to update in the created row. The sum should be separately calculated for each column …


Viewing all articles
Browse latest Browse all 767

Trending Articles