kyanuk1

Insert new row data into brand new table

Discussion created by kyanuk1 on Nov 5, 2012
Latest reply on Nov 5, 2012 by kyanuk1
Hello,

I am writing a model & script that performs a simple enumeration of calculations from a featureclass and adds the calculation to a new table which contains a concatenated field.

There are 128 fields and an unknown amount of rows that will be added.

The ArcPy help example shows creating a new row by manually specifying the fields:

while x <= 25: 
    row = rows.newRow() 
    row.rowid = x 
    row.distance = 100
    rows.insertRow(row) 
    x += 1


But this is a little heavy to write 128 fields to enter ...

I have this, but this is an incorrect way of writing a new row field by field:

tbl = 'Output'
tablerows = arcpy.InsertCursor(tbl)
fields = arcpy.ListFields(tbl)

for row in rows:
    tr = tablerows.newRow()
    for field in fields:
        #checking if the field matches the concatenated field created previously
        if (field.name == cField):
            try:
                cd = currentDemographic(row.getValue(g),row.getValue(r),row.getValue(a))
                #tr.field = cd  THIS IS WHAT IS INCORRECT (I Believe)
                #tablerows.insertRow(tr)
           except Exception,ex:
                print ex


What is the correct way of going about this with arcpy?

Thanks!

Outcomes