<?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: Text Element Questions in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/text-element-questions/m-p/326287#M25369</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Sorry I had misunderstood, your pageID variable is the value of the field, I had thought it was the field name. So yes you are right. PageID is supposed to be the field being searched and Intersec supposed to be the value of that field in the row. As your input you assign pageNum as the variable, this is supposed to be the page name but maybe you just have the page name set as a number?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Based on how I understand your code, I think this is what you want to be doing.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import arcpy
pageNum = arcpy.GetParameterAsText(0)
ddp = mxd.dataDrivenPages
arcpy.AddMessage(pageNum)
pageID = ddp.getPageIDFromName(str(pageNum))
ddp.currentPageID = pageID

rows = arcpy.SearchCursor(mapLyr, "{0} = {1}".format(ddp.pageNameField.name, pageNum))&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;That is assuming you are passing the page name as your parameter (pageNum). That is also assuming you are accessing the ddp layer in your cursor, if you are trying to access some other layer that would require some more creative solutions.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 11 Dec 2021 15:28:00 GMT</pubDate>
    <dc:creator>MathewCoyle</dc:creator>
    <dc:date>2021-12-11T15:28:00Z</dc:date>
    <item>
      <title>Text Element Questions</title>
      <link>https://community.esri.com/t5/python-questions/text-element-questions/m-p/326262#M25344</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;So I've got my text element function working in layout view, but it leaves me with two questions.&amp;nbsp; Can multiple rows be concatenated into the row.getValue or can it only find single fields?&amp;nbsp; Also, is it possible to return all feature records?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Here is the script I'm using to get the first result to fill the text box:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;import arcpy&amp;nbsp; mxd = arcpy.mapping.MapDocument("Current") mapLyr = arcpy.mapping.ListLayers(mxd, "Detail_2013")[0]&amp;nbsp; concatElem = arcpy.mapping.ListLayoutElements(mxd, "TEXT_ELEMENT", "concat")[0]&amp;nbsp; rows = arcpy.SearchCursor(mapLyr.dataSource) row = rows.next()&amp;nbsp; typeElem.text = row.getValue("CONCAT")&amp;nbsp; mxd.save() del mxd, row, rows,&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Any suggestions a much appreciated.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 14 Aug 2013 18:36:27 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/text-element-questions/m-p/326262#M25344</guid>
      <dc:creator>GeoffOlson</dc:creator>
      <dc:date>2013-08-14T18:36:27Z</dc:date>
    </item>
    <item>
      <title>Re: Text Element Questions</title>
      <link>https://community.esri.com/t5/python-questions/text-element-questions/m-p/326263#M25345</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;There are a few ways you could go about it. You can create a string variable and insert as many row values as you want is one way.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Here is an example of taking all values in the 'CONCAT' field.&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;rows = arcpy.SearchCursor(mapLyr.dataSource)
text_var = str()
for row in rows:
&amp;nbsp;&amp;nbsp;&amp;nbsp; text_var += '{0}{1}'.format(row.getValue("CONCAT"), os.linesep)

typeElem.text = text_var&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 15:27:31 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/text-element-questions/m-p/326263#M25345</guid>
      <dc:creator>MathewCoyle</dc:creator>
      <dc:date>2021-12-11T15:27:31Z</dc:date>
    </item>
    <item>
      <title>Re: Text Element Questions</title>
      <link>https://community.esri.com/t5/python-questions/text-element-questions/m-p/326264#M25346</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thanks for the reply.&amp;nbsp; I'm so excited it works!&amp;nbsp;&amp;nbsp; As you can probably tell, I'm very new to scripting.&amp;nbsp; To take that one step further, is it possible to add a second column to the text element after 5 rows of text?&amp;nbsp; I don't expect you to script that, but just if you know it can be done and what functions would be used.&amp;nbsp; I'm looking at using example 2 from the arcpy graphic element section in the help file.&amp;nbsp; Now I'm really excited to work my way through the "Python Scripting for ArcGIS" workbook.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 15 Aug 2013 11:07:08 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/text-element-questions/m-p/326264#M25346</guid>
      <dc:creator>GeoffOlson</dc:creator>
      <dc:date>2013-08-15T11:07:08Z</dc:date>
    </item>
    <item>
      <title>2 Text Elements for results</title>
      <link>https://community.esri.com/t5/python-questions/text-element-questions/m-p/326265#M25347</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I've thought on this a little more and I think I figured out how to go about this.&amp;nbsp; Right now I've got one text element that the search cursor is listing its results.&amp;nbsp; By adding a second text element in the map layout, can the script start putting "overflow" rows in it?&amp;nbsp; My goal would be to take my current script:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import arcpy

mxd = arcpy.mapping.MapDocument("Current")
mapLyr = arcpy.mapping.ListLayers(mxd, "Detail_2013")[0]

addrElem = arcpy.mapping.ListLayoutElements(mxd, "TEXT_ELEMENT", "concat1")[0]


rows = arcpy.SearchCursor(mapLyr.dataSource)
text_var = str()
for row in rows:
&amp;nbsp;&amp;nbsp;&amp;nbsp; text_var += '{0}{1}'.format(row.getValue("CONCAT"), os.linesep)

addrElem.text = text_var

mxd.save()
del mxd, row, rows,&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;and I would like to add a GetCount_management so the total number of records on the map page are returned, then divide that by two and the second half of the records returned would go to "concat2."&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I tried using gp.GetCount_management, but the Python windows says it doesn't know what "gp" is.&amp;nbsp; Is it part of the old arcgisscripting since import arcpy doesn't seem to know what it is?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 15:27:34 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/text-element-questions/m-p/326265#M25347</guid>
      <dc:creator>GeoffOlson</dc:creator>
      <dc:date>2021-12-11T15:27:34Z</dc:date>
    </item>
    <item>
      <title>Re: Text Element Questions</title>
      <link>https://community.esri.com/t5/python-questions/text-element-questions/m-p/326266#M25348</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;arcpy does recognize it:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.GetCount_management...&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 15 Aug 2013 15:28:03 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/text-element-questions/m-p/326266#M25348</guid>
      <dc:creator>T__WayneWhitley</dc:creator>
      <dc:date>2013-08-15T15:28:03Z</dc:date>
    </item>
    <item>
      <title>Re: Text Element Questions</title>
      <link>https://community.esri.com/t5/python-questions/text-element-questions/m-p/326267#M25349</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thank you, Wayne.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;lt;--Noob.:(&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 15 Aug 2013 15:31:06 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/text-element-questions/m-p/326267#M25349</guid>
      <dc:creator>GeoffOlson</dc:creator>
      <dc:date>2013-08-15T15:31:06Z</dc:date>
    </item>
    <item>
      <title>Re: Text Element Questions</title>
      <link>https://community.esri.com/t5/python-questions/text-element-questions/m-p/326268#M25350</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;...not really - I'm the noob for having to keep looking up the trick to get the result, as to convert to integer (I think directly a result object is returned), see this where the 'result' variable is the integer conversion:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;result = int(arcpy.GetCount_management(lyrfile).getOutput(0))&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://resources.arcgis.com/en/help/main/10.1/index.html#//0017000000n7000000" rel="nofollow noopener noreferrer" target="_blank"&gt;http://resources.arcgis.com/en/help/main/10.1/index.html#//0017000000n7000000&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Tricks!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Enjoy,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Wayne&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;EDIT-&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Maybe this isn't directly relevant, then again maybe it is -- another trick I saw again today (which I had forgotten was available) is interactive help call:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
&amp;gt;&amp;gt;&amp;gt; help(arcpy.GetCount_management)
Help on function GetCount in module arcpy.management:
 
GetCount(in_rows=None)
&amp;nbsp;&amp;nbsp;&amp;nbsp; GetCount_management(in_rows)
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Returns the total number of rows for a feature class, table, layer, or raster.
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; INPUTS:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; in_rows (Table View or Raster Layer):
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; The input feature class, table, layer, or raster. If a selection is defined on
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; the input, only its rows are returned.
 
&amp;gt;&amp;gt;&amp;gt;&amp;nbsp; 
&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 15:27:36 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/text-element-questions/m-p/326268#M25350</guid>
      <dc:creator>T__WayneWhitley</dc:creator>
      <dc:date>2021-12-11T15:27:36Z</dc:date>
    </item>
    <item>
      <title>Re: Text Element Questions</title>
      <link>https://community.esri.com/t5/python-questions/text-element-questions/m-p/326269#M25351</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Haha, yeah I just found that when I couldn't divide my result in half.&amp;nbsp; &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I just added these rows to the script:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;rowcount = int(arcpy.GetCount_management("Detail_2013").getOutput(0))
percolumn = round(rowcount / 2.0)&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I'm making improvements.&amp;nbsp; &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Now I just need to find out how to split the results.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 15:27:39 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/text-element-questions/m-p/326269#M25351</guid>
      <dc:creator>GeoffOlson</dc:creator>
      <dc:date>2021-12-11T15:27:39Z</dc:date>
    </item>
    <item>
      <title>Re: Text Element Questions</title>
      <link>https://community.esri.com/t5/python-questions/text-element-questions/m-p/326270#M25352</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;So I've tried different ways of limiting the iterations for the text element results and I've made a little bit of progress.&amp;nbsp; I added an if statement to try and control which iterations go to which text element, but it didn't do what it was supposed to.&amp;nbsp; Instead, I just have two copies of the full text elements.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import arcpy, os

mxd = arcpy.mapping.MapDocument("Current")
mapLyr = arcpy.mapping.ListLayers(mxd, "Detail_2013")[0]

concat1Elem = arcpy.mapping.ListLayoutElements(mxd, "TEXT_ELEMENT", "concat1")[0]
concat2Elem = arcpy.mapping.ListLayoutElements(mxd, "TEXT_ELEMENT", "concat2")[0]

rowcount = int(arcpy.GetCount_management("Detail_2013").getOutput(0))
percolumn = round(rowcount / 2.0)


rows = arcpy.SearchCursor(mapLyr.dataSource)



crnum = int()
for crashnum in rows:
&amp;nbsp;&amp;nbsp;&amp;nbsp; crnum = row.getValue("Crash_Num")

if crnum &amp;lt;= percolumn:
&amp;nbsp;&amp;nbsp;&amp;nbsp; text_var = str()
&amp;nbsp;&amp;nbsp;&amp;nbsp; for row in rows:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; text_var += '{0}{1}'.format(row.getValue("CONCAT"), os.linesep)
&amp;nbsp;&amp;nbsp;&amp;nbsp; concat1Elem.text = text_var
else:
&amp;nbsp;&amp;nbsp;&amp;nbsp; text_var = str()
&amp;nbsp;&amp;nbsp;&amp;nbsp; for row in rows:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; text_var += '{0}{1}'.format(row.getValue("CONCAT"), os.linesep)
&amp;nbsp;&amp;nbsp;&amp;nbsp; concat2Elem.text = text_var

mxd.save()
del mxd, row, rows, crnum,

print "First column should have :" + str(percolumn) + " rows." #used to check that it calculated properly&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I tried to use while and where but I couldn't figure out how or where to place those to get the script to run.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 15:27:42 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/text-element-questions/m-p/326270#M25352</guid>
      <dc:creator>GeoffOlson</dc:creator>
      <dc:date>2021-12-11T15:27:42Z</dc:date>
    </item>
    <item>
      <title>Re: Text Element Questions</title>
      <link>https://community.esri.com/t5/python-questions/text-element-questions/m-p/326271#M25353</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;If you want to split the items half between each text element you can add a counter and if statement to your cursor to only do half the rows as defined by your getcount method previously. I'm sure there is a better way of doing this but I just can't think of it right now.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;text_var = str()
count = 0
for row in rows:
&amp;nbsp;&amp;nbsp;&amp;nbsp; if count &amp;lt; percolumn:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; text_var += '{0}{1}'.format(row.getValue("CONCAT"), os.linesep)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; count += 1
&amp;nbsp;&amp;nbsp;&amp;nbsp; elif count == percolumn:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; concat1Elem.text = text_var
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; text_var = str()
&amp;nbsp;&amp;nbsp;&amp;nbsp; else:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; text_var += '{0}{1}'.format(row.getValue("CONCAT"), os.linesep)
concat2Elem.text = text_var&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 15:27:45 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/text-element-questions/m-p/326271#M25353</guid>
      <dc:creator>MathewCoyle</dc:creator>
      <dc:date>2021-12-11T15:27:45Z</dc:date>
    </item>
    <item>
      <title>Re: Text Element Questions</title>
      <link>https://community.esri.com/t5/python-questions/text-element-questions/m-p/326272#M25354</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I'm just thinking maybe the range function would apply here?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Since you know the total count couldn't you just run a loop, branching for the part of each half of the range?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;In general, illustrated by:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
&amp;gt;&amp;gt;&amp;gt; rowcount = 10
&amp;gt;&amp;gt;&amp;gt; for rows in range(rowcount):
 if rows in range(rowcount/2):
&amp;nbsp; print 'row ' + str(rows) + ' in range 1.'
 elif rows in range(rowcount/2, rowcount):
&amp;nbsp; print 'row ' + str(rows) + ' in range 2.'

&amp;nbsp; 
row 0 in range 1.
row 1 in range 1.
row 2 in range 1.
row 3 in range 1.
row 4 in range 1.
row 5 in range 2.
row 6 in range 2.
row 7 in range 2.
row 8 in range 2.
row 9 in range 2.
&amp;gt;&amp;gt;&amp;gt; 
&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 15:27:47 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/text-element-questions/m-p/326272#M25354</guid>
      <dc:creator>T__WayneWhitley</dc:creator>
      <dc:date>2021-12-11T15:27:47Z</dc:date>
    </item>
    <item>
      <title>Re: Text Element Questions</title>
      <link>https://community.esri.com/t5/python-questions/text-element-questions/m-p/326273#M25355</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;I'm just thinking maybe the range function would apply here?&lt;BR /&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Yes that's a nice method when you know the number of columns. Would need a slight tweak for odd numbers of rows.&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;rowcount = 9
for rows in range(rowcount):
&amp;nbsp;&amp;nbsp;&amp;nbsp; if rows in range(rowcount / 2 &lt;STRONG&gt;+ 1&lt;/STRONG&gt;):
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print 'row ' + str(rows) + ' in range 1.'
&amp;nbsp;&amp;nbsp;&amp;nbsp; elif rows in range(rowcount / 2, rowcount):
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print 'row ' + str(rows) + ' in range 2.'&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;There was also this for a tool that can take a dynamic number of text columns (as long as they are already created and follow the naming/number convention).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import os
import arcpy


def main():

&amp;nbsp;&amp;nbsp;&amp;nbsp; layer_name = arcpy.GetParameterAsText(0)
&amp;nbsp;&amp;nbsp;&amp;nbsp; field = arcpy.GetParameterAsText(1)
&amp;nbsp;&amp;nbsp;&amp;nbsp; number_columns = float(arcpy.GetParameterAsText(2))

&amp;nbsp;&amp;nbsp;&amp;nbsp; mxd = arcpy.mapping.MapDocument("Current")
&amp;nbsp;&amp;nbsp;&amp;nbsp; mapLyr = arcpy.mapping.ListLayers(mxd, layer_name)[0]

&amp;nbsp;&amp;nbsp;&amp;nbsp; rowcount = int(arcpy.GetCount_management(layer_name).getOutput(0))
&amp;nbsp;&amp;nbsp;&amp;nbsp; percolumn = round(rowcount / number_columns)

&amp;nbsp;&amp;nbsp;&amp;nbsp; text_var = str()
&amp;nbsp;&amp;nbsp;&amp;nbsp; item_count = 0
&amp;nbsp;&amp;nbsp;&amp;nbsp; column_count = 1
&amp;nbsp;&amp;nbsp;&amp;nbsp; for row in arcpy.SearchCursor(mapLyr.dataSource, sort_fields='{0} A'.format(field)):
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; text_var += '{0}{1}'.format(row.getValue(field), os.linesep)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; item_count += 1
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; column = 'concat{0}'.format(column_count)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddMessage(item_count)

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if item_count == percolumn and column_count != number_columns:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddMessage('next column')
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.mapping.ListLayoutElements(mxd, "TEXT_ELEMENT", column)[0].text = text_var
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; text_var = str()
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; column_count += 1
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; item_count = 0

&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.mapping.ListLayoutElements(mxd, "TEXT_ELEMENT", column)[0].text = text_var

&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.RefreshActiveView()
&amp;nbsp;&amp;nbsp;&amp;nbsp; mxd.save()
&amp;nbsp;&amp;nbsp;&amp;nbsp; del mxd

&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddMessage("First column should have : {0} rows.".format(percolumn))&amp;nbsp; #used to check that it calculated properly

if __name__ == '__main__':
&amp;nbsp;&amp;nbsp;&amp;nbsp; main()

&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 15:27:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/text-element-questions/m-p/326273#M25355</guid>
      <dc:creator>MathewCoyle</dc:creator>
      <dc:date>2021-12-11T15:27:50Z</dc:date>
    </item>
    <item>
      <title>Re: Text Element Questions</title>
      <link>https://community.esri.com/t5/python-questions/text-element-questions/m-p/326274#M25356</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thanks for all the help, guys!&amp;nbsp; I have the if statement almost working.&amp;nbsp; The second column works fine, but the first column is only returning the last result.&amp;nbsp; I have a field that numbers each row in the table, besides the FID, so that way on each map page each row of text is numbered and it matches the label in the map.&amp;nbsp; Instead of using a counter += 1, can an attribute field be used instead?&amp;nbsp; I have the field "Crash_Num" that numbers each feature in the map for each page but I don't know how to use a searchcursor and getValue.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 16 Aug 2013 12:40:38 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/text-element-questions/m-p/326274#M25356</guid>
      <dc:creator>GeoffOlson</dc:creator>
      <dc:date>2013-08-16T12:40:38Z</dc:date>
    </item>
    <item>
      <title>Re: Text Element Questions</title>
      <link>https://community.esri.com/t5/python-questions/text-element-questions/m-p/326275#M25357</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Are you using Mathew's code?&amp;nbsp; (If so, you should award him points and/or the answer when you finally get things running.)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;As 'extra' help, this is where the row from your table value for the 'field' is passed (from Mathew's last posted code):&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
for row in arcpy.SearchCursor(mapLyr.dataSource, sort_fields='{0} A'.format(field)):
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; text_var += '{0}{1}'.format(row.getValue(field), os.linesep)
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;EDIT:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Actually, in that 1st line above, all your table fields are being passed in, just that the one specified as 'field' (assigned at the SetParam statement at the beginning) is used for sorting.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;So you could 'look up' other field values by inserting a line within the loop such as:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
aNewTxtVar = row.getValue('yourDesignatedFieldname')
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;(see getValue for the SearchCursor in the webhelp)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Anyway, hope that helps!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Enjoy,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Wayne&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 15:27:52 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/text-element-questions/m-p/326275#M25357</guid>
      <dc:creator>T__WayneWhitley</dc:creator>
      <dc:date>2021-12-11T15:27:52Z</dc:date>
    </item>
    <item>
      <title>Re: Text Element Questions</title>
      <link>https://community.esri.com/t5/python-questions/text-element-questions/m-p/326276#M25358</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I think I just got it working.&amp;nbsp; Here's the final script:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import arcpy, os

mxd = arcpy.mapping.MapDocument("Current")
mapLyr = arcpy.mapping.ListLayers(mxd, "Detail_2013")[0]

concatElem1 = arcpy.mapping.ListLayoutElements(mxd, "TEXT_ELEMENT", "concat1")[0]
concatElem2 = arcpy.mapping.ListLayoutElements(mxd, "TEXT_ELEMENT", "concat2")[0]

rowcount = int(arcpy.GetCount_management("Detail_2013").getOutput(0))
percolumn = round(rowcount / 2.0)
count1 = 1
count2 = rowcount

rows = arcpy.SearchCursor(mapLyr.dataSource)

text_var1 = str()
text_var2 = str()

for row in rows:
&amp;nbsp;&amp;nbsp;&amp;nbsp; if count1 &amp;lt;= percolumn:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; text_var1 += '{0}{1}'.format(row.getValue("CONCAT"), os.linesep)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; concatElem1.text = text_var1
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; count1 += 1
&amp;nbsp;&amp;nbsp;&amp;nbsp; elif count2 &amp;gt; percolumn:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; text_var2 += '{0}{1}'.format(row.getValue("CONCAT"), os.linesep)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; concatElem2.text = text_var2
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; count2 - 1
&amp;nbsp;&amp;nbsp;&amp;nbsp; else:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; pass
mxd.save()
del mxd, row, rows,&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 15:27:55 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/text-element-questions/m-p/326276#M25358</guid>
      <dc:creator>GeoffOlson</dc:creator>
      <dc:date>2021-12-11T15:27:55Z</dc:date>
    </item>
    <item>
      <title>Python disregarding DDP Page Query</title>
      <link>https://community.esri.com/t5/python-questions/text-element-questions/m-p/326277#M25359</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;The only problem I have now is the script isn't following the page definition query.&amp;nbsp; Only the queried features appear in the attribute table, but the script lists all features, even the ones that are queried out.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 16 Aug 2013 14:50:59 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/text-element-questions/m-p/326277#M25359</guid>
      <dc:creator>GeoffOlson</dc:creator>
      <dc:date>2013-08-16T14:50:59Z</dc:date>
    </item>
    <item>
      <title>Re: Text Element Questions</title>
      <link>https://community.esri.com/t5/python-questions/text-element-questions/m-p/326278#M25360</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Well you have options - that's the good news.&amp;nbsp; The searchcursor input parameter works on a layer (the 1st param)...or you could optionally enter a query filter...see the syntax and explanation at the link below:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;usage:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;SearchCursor (in_table, field_names, {where_clause}, {spatial_reference}, {explode_to_points}, {sql_clause})&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://resources.arcgis.com/en/help/main/10.1/index.html#//018w00000011000000"&gt;http://resources.arcgis.com/en/help/main/10.1/index.html#//018w00000011000000&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;oops, that one was for the da (data access) search cursor.... you need this one:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;SearchCursor (dataset, {where_clause}, {spatial_reference}, {fields}, {sort_fields})&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://resources.arcgis.com/en/help/main/10.1/index.html#//018v00000050000000"&gt;http://resources.arcgis.com/en/help/main/10.1/index.html#//018v00000050000000&lt;/A&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 16 Aug 2013 15:05:01 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/text-element-questions/m-p/326278#M25360</guid>
      <dc:creator>T__WayneWhitley</dc:creator>
      <dc:date>2013-08-16T15:05:01Z</dc:date>
    </item>
    <item>
      <title>Re: Text Element Questions</title>
      <link>https://community.esri.com/t5/python-questions/text-element-questions/m-p/326279#M25361</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Using a SearchCursor should filter out which rows are being returned?&amp;nbsp; Can multiple row.getValue functions be used?&amp;nbsp; I was concerned the "for row from rows:" would have assigned a value to row and couldn't be used twice, and a different variable be created in place of row?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Manually setting a definition query also fails to limit which rows get searched.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 16 Aug 2013 16:26:10 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/text-element-questions/m-p/326279#M25361</guid>
      <dc:creator>GeoffOlson</dc:creator>
      <dc:date>2013-08-16T16:26:10Z</dc:date>
    </item>
    <item>
      <title>Re: Text Element Questions</title>
      <link>https://community.esri.com/t5/python-questions/text-element-questions/m-p/326280#M25362</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;You should post your code and any error msgs you're receiving...&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;In short, yes you can get another field value from the row object.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Incidentally, you could say 'for browncow in rows' and you are still implicitly getting a row object from the cursor.&amp;nbsp; (why simply using 'row' is often used)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I suspect your where_clause query is faulty, but have no idea since there's no posted code, etc.&amp;nbsp; Don't forget to post the error msg too!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 16 Aug 2013 16:35:15 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/text-element-questions/m-p/326280#M25362</guid>
      <dc:creator>T__WayneWhitley</dc:creator>
      <dc:date>2013-08-16T16:35:15Z</dc:date>
    </item>
    <item>
      <title>Re: Text Element Questions</title>
      <link>https://community.esri.com/t5/python-questions/text-element-questions/m-p/326281#M25363</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I added this to get the page name:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
pageNum = arcpy.GetParameterAsText(0)
ddp = mxd.dataDrivenPages
arcpy.AddMessage(pageNum)
pageID = mxd.dataDrivenPages.getPageIDFromName(str(pageNum))
mxd.dataDrivenPages.currentPageID = pageID&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;and I changed the SearchCursor to this:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;rows = arcpy.SearchCursor(mapLyr.dataSource, "PageID = \'Intersec\'")&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;but I get an error saying the fields in the search cursor do not exits.&amp;nbsp; I'm trying to set the field value to the page name.&amp;nbsp; The other thing that happens is the page name seems to only be stored as a page number and not the specified index layer field.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 15:27:58 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/text-element-questions/m-p/326281#M25363</guid>
      <dc:creator>GeoffOlson</dc:creator>
      <dc:date>2021-12-11T15:27:58Z</dc:date>
    </item>
  </channel>
</rss>

