<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Label from a related table using Label Expression in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/label-from-a-related-table-using-label-expression/m-p/156057#M12021</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The dataset is relatively small so I don't need a dictionary.&amp;nbsp; Basically just looking for the python version of this VBScript that I found:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Function FindLabel ( [RelateFieldofLayer] )&lt;/P&gt;&lt;P&gt;Set gp = CreateObject("esriGeoprocessing.GPDispatch.1")&lt;/P&gt;&lt;P&gt;strWhereClause = chr(34) &amp;amp; "RelateFieldofTable" &amp;amp; chr(34) &amp;amp; " = '" &amp;amp; [RelateFieldofLayer] &amp;amp; "'"&lt;/P&gt;&lt;P&gt;strpTable = "PathToRelatedTable"&lt;/P&gt;&lt;P&gt;Set prows = gp.searchcursor(strpTable,strWhereClause) &lt;/P&gt;&lt;P&gt;Set prow = prows.next&lt;/P&gt;&lt;P&gt;Do until prow is nothing&lt;/P&gt;&lt;P&gt;strLabel = prow.LabelField&lt;/P&gt;&lt;P&gt;FindLabel = FindLabel &amp;amp; strLabel &amp;amp; vbnewline&lt;/P&gt;&lt;P&gt;Set prow = prows.next&lt;/P&gt;&lt;P&gt;Loop&lt;/P&gt;&lt;P&gt;End Function&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 25 Apr 2016 21:39:26 GMT</pubDate>
    <dc:creator>DamonOsbourne</dc:creator>
    <dc:date>2016-04-25T21:39:26Z</dc:date>
    <item>
      <title>Label from a related table using Label Expression</title>
      <link>https://community.esri.com/t5/python-questions/label-from-a-related-table-using-label-expression/m-p/156055#M12019</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Looking for a label expression that will label from a relate.&amp;nbsp; It's a 1-to-many situation &amp;amp; desired result is to stack the labels from a field in the related table.&amp;nbsp; 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.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 18 Apr 2016 15:16:31 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/label-from-a-related-table-using-label-expression/m-p/156055#M12019</guid>
      <dc:creator>DamonOsbourne</dc:creator>
      <dc:date>2016-04-18T15:16:31Z</dc:date>
    </item>
    <item>
      <title>Re: Label from a related table using Label Expression</title>
      <link>https://community.esri.com/t5/python-questions/label-from-a-related-table-using-label-expression/m-p/156056#M12020</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;See &lt;A href="https://community.esri.com/migration-blogpost/1456"&gt;Richard Fairhurst's Blog&lt;/A&gt;​ &lt;A href="https://community.esri.com/migration-blogpost/2492"&gt;Creating Labels with Related Table Data&lt;/A&gt; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 18 Apr 2016 16:03:40 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/label-from-a-related-table-using-label-expression/m-p/156056#M12020</guid>
      <dc:creator>WesMiller</dc:creator>
      <dc:date>2016-04-18T16:03:40Z</dc:date>
    </item>
    <item>
      <title>Re: Label from a related table using Label Expression</title>
      <link>https://community.esri.com/t5/python-questions/label-from-a-related-table-using-label-expression/m-p/156057#M12021</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The dataset is relatively small so I don't need a dictionary.&amp;nbsp; Basically just looking for the python version of this VBScript that I found:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Function FindLabel ( [RelateFieldofLayer] )&lt;/P&gt;&lt;P&gt;Set gp = CreateObject("esriGeoprocessing.GPDispatch.1")&lt;/P&gt;&lt;P&gt;strWhereClause = chr(34) &amp;amp; "RelateFieldofTable" &amp;amp; chr(34) &amp;amp; " = '" &amp;amp; [RelateFieldofLayer] &amp;amp; "'"&lt;/P&gt;&lt;P&gt;strpTable = "PathToRelatedTable"&lt;/P&gt;&lt;P&gt;Set prows = gp.searchcursor(strpTable,strWhereClause) &lt;/P&gt;&lt;P&gt;Set prow = prows.next&lt;/P&gt;&lt;P&gt;Do until prow is nothing&lt;/P&gt;&lt;P&gt;strLabel = prow.LabelField&lt;/P&gt;&lt;P&gt;FindLabel = FindLabel &amp;amp; strLabel &amp;amp; vbnewline&lt;/P&gt;&lt;P&gt;Set prow = prows.next&lt;/P&gt;&lt;P&gt;Loop&lt;/P&gt;&lt;P&gt;End Function&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 25 Apr 2016 21:39:26 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/label-from-a-related-table-using-label-expression/m-p/156057#M12021</guid>
      <dc:creator>DamonOsbourne</dc:creator>
      <dc:date>2016-04-25T21:39:26Z</dc:date>
    </item>
    <item>
      <title>Re: Label from a related table using Label Expression</title>
      <link>https://community.esri.com/t5/python-questions/label-from-a-related-table-using-label-expression/m-p/156058#M12022</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I got the below to work but it's really slow.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;def FindLabel ( [RelateFieldofTable] ):
&amp;nbsp;&amp;nbsp;&amp;nbsp; strWhereClause = '"' + "RelateFieldofTable" + '"' +&amp;nbsp; " = '" + [RelateFieldofTable] + "'"
&amp;nbsp;&amp;nbsp;&amp;nbsp; strpTable =&amp;nbsp; "PathToRelatedTable" 
&amp;nbsp;&amp;nbsp;&amp;nbsp; rows = arcpy.SearchCursor(strpTable,strWhereClause)
&amp;nbsp;&amp;nbsp;&amp;nbsp; strLabel = ''
&amp;nbsp;&amp;nbsp;&amp;nbsp; for row in rows:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; strLabel += '\n'+ row.FieldToLabel
&amp;nbsp;&amp;nbsp;&amp;nbsp; return [RelateFieldofTable] + strLabel &lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 08:17:13 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/label-from-a-related-table-using-label-expression/m-p/156058#M12022</guid>
      <dc:creator>WesMiller</dc:creator>
      <dc:date>2021-12-11T08:17:13Z</dc:date>
    </item>
  </channel>
</rss>

