Here is how I got it to work. I would still prefer to find a way to do this without creating all the feature layers and appending. Ideas?????
import arcpy
arcpy.env.overwriteOutput = True
fc = "C:\\Amy\\Test.gdb\\SubAcreTest_p"
ntbl = "C:\\Amy\\Test.gdb\\Neighbor_tbl"
sorttbl = "C:\\Amy\\Test.gdb\\tbl_sort"
stattbl = "C:\\Amy\\Test.gdb\\tbl_stat"
arcpy.AddMessage("Performing neighbor analysis....")
arcpy.PolygonNeighbors_analysis(fc, ntbl, "OBJECTID;Acre;SHAPE_Length;SHAPE_Area;Letter", "NO_AREA_OVERLAP", "BOTH_SIDES", "", "FEET", "SQUARE_METERS")
sc = arcpy.da.UpdateCursor(ntbl, ['src_Acre', 'NODE_COUNT'])
arcpy.AddMessage("Removing polygons larger or equal to 1 acre and removing node polygons from neighbor table....")
for s in sc:
if s[0] > 1:
sc.deleteRow()
elif s[1] == 1:
sc.deleteRow()
del s, sc
arcpy.AddMessage("Making sort table....")
arcpy.Sort_management(ntbl, sorttbl, "src_Acre ASCENDING;nbr_Letter ASCENDING", "UR") #making sure the first letter choice is first in position for stat table to isolate
arcpy.AddMessage("Making summary statistics table....")
arcpy.Statistics_analysis(sorttbl, stattbl, "nbr_Letter FIRST;nbr_OBJECTID FIRST", "src_OBJECTID") #make table (used in query) for selecting the first letter and coresponding object id's to be merged
arcpy.env.workspace = "C:\\Amy\\Test.gdb\\polyfiles" #feature dataset
#searching for object id's in stat table to use in query of final feature class
#code will grab object id's from stat table, make a feature layer of 2 polygons to be dissolved and dissolve them, delete individual polygons from final layer and append the dissolved polygon into the final feature class
cursor = arcpy.da.SearchCursor(stattbl, "*")
for row in cursor:
OID1 = row[1]
OID2 = row[4]
arcpy.AddMessage("Merging layers for Object ID's: " + str(OID1) + " and " + str(OID2))
where_clause = "OBJECTID = %s OR OBJECTID = %s"%(OID1,OID2)
arcpy.MakeFeatureLayer_management(fc, "tmplyr", where_clause)
diss_name = "Dissolve_%s_%s"%(OID1,OID2)
sort_name = "Sort_%s_%s"%(OID1,OID2)
arcpy.Sort_management("tmplyr", sort_name, "Letter ASCENDING", "UR")
arcpy.Dissolve_management(sort_name, diss_name, "", "Acre MAX;Letter LAST", "MULTI_PART", "DISSOLVE_LINES")
uc = arcpy.da.UpdateCursor(fc, "OBJECTID")
for u in uc:
if u[0] == OID1:
uc.deleteRow()
elif u[0] == OID2:
uc.deleteRow()
arcpy.Append_management(diss_name, fc, "NO_TEST", "Acre \"Acre\" true true false 8 Double 0 0 ,First,#,Dissolve_1_5,MAX_Acre,-1,-1;Letter \"Letter\" true true false 10 Text 0 0 ,First,#,Dissolve_1_5,LAST_Letter,-1,-1;SHAPE_Length \"SHAPE_Length\" false true true 8 Double 0 0 ,First,#,Dissolve_1_5,SHAPE_Length,-1,-1;SHAPE_Area \"SHAPE_Area\" false true true 8 Double 0 0,First,#,Dissolve_1_5,SHAPE_Area,-1,-1", "")
del u, uc
del row, cursor