Looking for a label expression that will label from a relate. It's a 1-to-many situation & desired result is to stack the labels from a field in the related table. For example, it would be how a city would label tenants in one building, or like labeling residents (listed in a xls) on 1 apartment building.
The dataset is relatively small so I don't need a dictionary. Basically just looking for the python version of this VBScript that I found:
Function FindLabel ( [RelateFieldofLayer] )
Set gp = CreateObject("esriGeoprocessing.GPDispatch.1")
strWhereClause = chr(34) & "RelateFieldofTable" & chr(34) & " = '" & [RelateFieldofLayer] & "'"
strpTable = "PathToRelatedTable"
Set prows = gp.searchcursor(strpTable,strWhereClause)
Set prow = prows.next
Do until prow is nothing
strLabel = prow.LabelField
FindLabel = FindLabel & strLabel & vbnewline
Set prow = prows.next
Loop
End Function
I got the below to work but it's really slow.
def FindLabel ( [RelateFieldofTable] ): strWhereClause = '"' + "RelateFieldofTable" + '"' + " = '" + [RelateFieldofTable] + "'" strpTable = "PathToRelatedTable" rows = arcpy.SearchCursor(strpTable,strWhereClause) strLabel = '' for row in rows: strLabel += '\n'+ row.FieldToLabel return [RelateFieldofTable] + strLabel