import arcpy
arcpy.env.overwriteOutput = True
sourceFC = r'\\qep\dnshare\GIS\Haynesville\WorkspaceGDBs\HaynesvilleRecovery.gdb\sticksRF_split'
field_names = []
fields = arcpy.ListFields(sourceFC)
for field in fields:
if field.editable:
field_names.append(field.name)
all_editable_fields = field_names
sourceFieldsList = ["PROPNUM_GIS", "Shape_Length"] + all_editable_fields
print sourceFieldsList
valueDict = {}
with arcpy.da.SearchCursor(sourceFC, sourceFieldsList) as searchRows:
for searchRow in searchRows:
keyValue = searchRow[0]
if not keyValue in valueDict:
valueDict[keyValue] = [searchRow[1:]]
elif valueDict[keyValue][0] < searchRow[1]:
valueDict[keyValue] = [searchRow[1:]]
print valueDict
arcpy.CreateFeatureclass_management(r'\\qep\dnshare\GIS\Haynesville\WorkspaceGDBs\HaynesvilleRecovery.gdb', "sticksTrimmed", "POLYLINE", sourceFC, "DISABLED", "DISABLED", sourceFC)
lines = arcpy.da.InsertCursor(r'\\qep\dnshare\GIS\Haynesville\WorkspaceGDBs\HaynesvilleRecovery.gdb\sticksTrimmed', all_editable_fields)
for propnum_gis in valueDict:
fieldValues = valueDict[propnum_gis][1:]
Thanks Richard. I tried your code with some slight modifications, as shown above. The output feature class, sticksTrimmed, is empty. However, it does contain all of the necessary fields. I'm not really sure what is going on with the dictionary and if-elif statements, so I'm a bit stumped. One thing I did notice is that when I print valueDict, the key-value combinations are not really comparable. For example:
{u'J7MIIN2UFQ': [(1368.5519332219944, (468190.93242110324, 3570500.798905503), u'J7MIIN2UFQ', u'1PDP', 1632.66115520795, None, 5584814.0, None, 4490.0, 1368.5520000000001)], ...}
I'm going to try to simplify this a bit, since all I really need in the output is the geometry and PROPNUM values.