AnsweredAssumed Answered

Inject/Combine fields

Question asked by CCweedcontrol on Jan 17, 2018
Latest reply on Jan 17, 2018 by Dan_Patterson

I have two tables i need to be able to inject two fields attributes into the other table.

Table2 has two fields, 'STREET' & 'STATUS' i need to be able to inject those fields attributes into Table 1(Table1 also has two fields, 'STREET' & 'STATUS' ). I am able to get one field attributes from Table 2 injected into Table 1 but i am not sure how to inject two.

 

I get

 

line 46, in <module>
    insertCursor.insertRow(i)
TypeError: sequence size must match size of the row

 

import arcpy


##Updates CurrentRoadNames Table with just ORN table.

#Will update ParcelTool database on SDE   
arcpy.env.workspace = r"C:\Temp\Default.gdb"

# Get a list of all the tables.
tableList = arcpy.ListTables('CurrntRoadNamesTableTest')

# Loop through the list and run truncate
for table in tableList:
    arcpy.TruncateTable_management(table)

table1 = r'C:\Temp\Default.gdb\CurrntRoadNamesTableTest'
table2 = r"C:\Temp\Default.gdbORN table
#table3 = #Centerline

####Compare and inject missing street names from ORN table
####

table1List = []
with arcpy.da.SearchCursor(table1, ['STREET','STATUS']) as cursor:
    for row in cursor:
        table1List.append(row[0])
del cursor

#list of fields whose will need to be imported into table2
fields = ['Street']

#list of values from table1 to inject into table2
ids = []

with arcpy.da.SearchCursor(table2, ['FULLSTNAME', 'STATUS']) as cursor:
    for row in cursor:
            if row[0] not in table1List:
                ids.append(row[0:])
del cursor

#create insert cursor variable
insertCursor = arcpy.da.InsertCursor(table1,fields)

#loop through items in ids list and insert into table
for i in ids:
    insertCursor.insertRow(i)
del insertCursor

print 'Done'

Outcomes