Last active
July 14, 2016 23:12
-
-
Save gisdev-km/ffce799fcdf8fea135b0c17dfbf4db21 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
relateDict = {} | |
def FindLabel ( [TurnoutID] ): | |
global relateDict | |
if len(relateDict) == 0: | |
## FIX THIS! | |
relateFC = r"<connection path on disk>" | |
## | |
relateFieldsList = ["TurnOutID", "FieldNumber"] | |
with arcpy.da.SearchCursor(relateFC, relateFieldsList) as relateRows: | |
for relateRow in relateRows: | |
relateKey = relateRow[0] | |
if not relateKey in relateDict: | |
relateDict[relateKey] = [relateRow[1]] | |
else: | |
relateDict[relateKey].append(relateRow[1]) | |
del relateRows, relateRow | |
labelKey = [TurnOutID] | |
expression = '<FNT name="Arial" size="12"><BOL>{0}</BOL></FNT>'.format(labelKey) | |
if labelKey in relateDict: | |
sortedList = sorted(relateDict[labelKey]) | |
# Comment this out if you dont want the count | |
expression += '\n<FNT name="Arial" size="10">Record Count: {0}</FNT>'.format(len(sortedList)) | |
for fieldValue in sortedList: | |
expression += '\n{0}'.format(fieldValue) | |
del sortedList, fieldValue | |
else: | |
expression += '\n<FNT name="Arial" size="10">--</FNT>' | |
return expression |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment