<?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 Python Script to Create Table Using Data Driven Pages in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/python-script-to-create-table-using-data-driven/m-p/583636#M45764</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I am trying to convert some python script to display a table (based on a dbf) of features located within a specific data driven page. So far, I have the script successfully able to refresh the map to the specific table, but it does not update the table.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I have it set-up as three text boxes that should be updated with three specific fields when the user runs the script from ArcToolbox. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Any suggestions on why my table is not updating?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;
#Reference current MXD
mxd = arcpy.mapping.MapDocument("current")

#Get input parameter
Name = arcpy.GetParameterAsText(0)

#Reference&amp;nbsp; data frames
mapatlasDF = arcpy.mapping.ListDataFrames(mxd, "Layers")[0]
locatorDF = arcpy.mapping.ListDataFrames(mxd, "Locator Map")[0]

#Reference appropriate layers
atlasLyr = arcpy.mapping.ListLayers(mxd, "PinalCreekMapAtlas_HalfMile", mapatlasDF)[0]
locatorLyr = arcpy.mapping.ListLayers(mxd, "Locator Map", locatorDF)[0]
atlasoutlineLyr = arcpy.mapping.ListLayers(mxd, "Map Atlas Outline", locatorDF)[0]

#Reference layout elements by calling ListLayoutElements 
for elm in arcpy.mapping.ListLayoutElements(mxd):
&amp;nbsp; if elm.name =="Table1Column1": tab1Col1Txt = elm
&amp;nbsp; if elm.name =="Table1Column2": tab1Col2Txt = elm
&amp;nbsp; if elm.name =="Table1Column3": tab1Col3Txt = elm

#Reference the Data Driven Page object
ddp = mxd.dataDrivenPages

#Set the current page to be the one selected in the script tool
arcpy.AddMessage(Name)

pageID = mxd.dataDrivenPages.getPageIDFromName(str(Name))
mxd.dataDrivenPages.currentPageID = pageID

#Set the appropriate definition queries
atlasLyr.definitionQuery = "Name = '" + Name +&amp;nbsp; "'"
locatorLyr.definitionQuery = "Name = '" + Name +&amp;nbsp; "'"
atlasoutlineLyr.definitionQuery = "Name &amp;lt;&amp;gt; '" + Name +&amp;nbsp; "'"

#Update Sheet Index data frame
arcpy.SelectLayerByAttribute_management(locatorLyr, "NEW_SELECTION", "\"Name\" = '" + Name + "'")
locatorDF.panToExtent(locatorLyr.getSelectedExtent())

#Reference Affected Parcels table and select appropriate records
parcelTable = arcpy.mapping.ListTableViews(mxd, "AffectedParcels")[0]

#Build query and create search cursor to loop through rows
parcelFieldValue = "Page " + Name
queryExp = "\"MapPage\" = '" + parcelFieldValue + "'"&amp;nbsp; #e.g., "MapPage" = 'Page 01'
parcelRows = arcpy.SearchCursor(parcelTable.dataSource, queryExp)

#Clear all table text values
tab1Col1Txt.text = " "; tab1Col2Txt.text = " "; tab1Col3Txt.text = " "

#iteate through each row, update appropiate text
count = 0
for row in parcelRows:
&amp;nbsp; if count &amp;lt; 30: #Table1 - static position
&amp;nbsp;&amp;nbsp;&amp;nbsp; tab1Col1Txt.text = tab1Col1Txt.text + row.getValue("OwnerName") +"\n"
&amp;nbsp;&amp;nbsp;&amp;nbsp; tab1Col2Txt.text = tab1Col2Txt.text + row.getValue("APN") + "\n"
&amp;nbsp;&amp;nbsp;&amp;nbsp; tab1Col3Txt.text = tab1Col3Txt.text + row.getValue("LengthTrail") + "\n"
&amp;nbsp; if count ==30:&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddMessage("Table Overflow") #The code could be reworked to show the last 90 records
&amp;nbsp; count = count + 1

arcpy.RefreshActiveView()
arcpy.AddMessage("PROCESS COMPLETED")
&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 30 Apr 2012 16:26:14 GMT</pubDate>
    <dc:creator>PhyllisDavis</dc:creator>
    <dc:date>2012-04-30T16:26:14Z</dc:date>
    <item>
      <title>Python Script to Create Table Using Data Driven Pages</title>
      <link>https://community.esri.com/t5/python-questions/python-script-to-create-table-using-data-driven/m-p/583636#M45764</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I am trying to convert some python script to display a table (based on a dbf) of features located within a specific data driven page. So far, I have the script successfully able to refresh the map to the specific table, but it does not update the table.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I have it set-up as three text boxes that should be updated with three specific fields when the user runs the script from ArcToolbox. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Any suggestions on why my table is not updating?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;
#Reference current MXD
mxd = arcpy.mapping.MapDocument("current")

#Get input parameter
Name = arcpy.GetParameterAsText(0)

#Reference&amp;nbsp; data frames
mapatlasDF = arcpy.mapping.ListDataFrames(mxd, "Layers")[0]
locatorDF = arcpy.mapping.ListDataFrames(mxd, "Locator Map")[0]

#Reference appropriate layers
atlasLyr = arcpy.mapping.ListLayers(mxd, "PinalCreekMapAtlas_HalfMile", mapatlasDF)[0]
locatorLyr = arcpy.mapping.ListLayers(mxd, "Locator Map", locatorDF)[0]
atlasoutlineLyr = arcpy.mapping.ListLayers(mxd, "Map Atlas Outline", locatorDF)[0]

#Reference layout elements by calling ListLayoutElements 
for elm in arcpy.mapping.ListLayoutElements(mxd):
&amp;nbsp; if elm.name =="Table1Column1": tab1Col1Txt = elm
&amp;nbsp; if elm.name =="Table1Column2": tab1Col2Txt = elm
&amp;nbsp; if elm.name =="Table1Column3": tab1Col3Txt = elm

#Reference the Data Driven Page object
ddp = mxd.dataDrivenPages

#Set the current page to be the one selected in the script tool
arcpy.AddMessage(Name)

pageID = mxd.dataDrivenPages.getPageIDFromName(str(Name))
mxd.dataDrivenPages.currentPageID = pageID

#Set the appropriate definition queries
atlasLyr.definitionQuery = "Name = '" + Name +&amp;nbsp; "'"
locatorLyr.definitionQuery = "Name = '" + Name +&amp;nbsp; "'"
atlasoutlineLyr.definitionQuery = "Name &amp;lt;&amp;gt; '" + Name +&amp;nbsp; "'"

#Update Sheet Index data frame
arcpy.SelectLayerByAttribute_management(locatorLyr, "NEW_SELECTION", "\"Name\" = '" + Name + "'")
locatorDF.panToExtent(locatorLyr.getSelectedExtent())

#Reference Affected Parcels table and select appropriate records
parcelTable = arcpy.mapping.ListTableViews(mxd, "AffectedParcels")[0]

#Build query and create search cursor to loop through rows
parcelFieldValue = "Page " + Name
queryExp = "\"MapPage\" = '" + parcelFieldValue + "'"&amp;nbsp; #e.g., "MapPage" = 'Page 01'
parcelRows = arcpy.SearchCursor(parcelTable.dataSource, queryExp)

#Clear all table text values
tab1Col1Txt.text = " "; tab1Col2Txt.text = " "; tab1Col3Txt.text = " "

#iteate through each row, update appropiate text
count = 0
for row in parcelRows:
&amp;nbsp; if count &amp;lt; 30: #Table1 - static position
&amp;nbsp;&amp;nbsp;&amp;nbsp; tab1Col1Txt.text = tab1Col1Txt.text + row.getValue("OwnerName") +"\n"
&amp;nbsp;&amp;nbsp;&amp;nbsp; tab1Col2Txt.text = tab1Col2Txt.text + row.getValue("APN") + "\n"
&amp;nbsp;&amp;nbsp;&amp;nbsp; tab1Col3Txt.text = tab1Col3Txt.text + row.getValue("LengthTrail") + "\n"
&amp;nbsp; if count ==30:&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddMessage("Table Overflow") #The code could be reworked to show the last 90 records
&amp;nbsp; count = count + 1

arcpy.RefreshActiveView()
arcpy.AddMessage("PROCESS COMPLETED")
&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 30 Apr 2012 16:26:14 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-script-to-create-table-using-data-driven/m-p/583636#M45764</guid>
      <dc:creator>PhyllisDavis</dc:creator>
      <dc:date>2012-04-30T16:26:14Z</dc:date>
    </item>
    <item>
      <title>Re: Python Script to Create Table Using Data Driven Pages</title>
      <link>https://community.esri.com/t5/python-questions/python-script-to-create-table-using-data-driven/m-p/583637#M45765</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;This code looks really familiar, did you get it from the Dynamic Graphic Table sample?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;At a quick glance, the code looks fine.&amp;nbsp; Are you sure your query is working and that rows are being returned?&amp;nbsp; You should try adding a "print count" statement to see if count is &amp;gt; 0.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Jeff&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 01 May 2012 14:01:39 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-script-to-create-table-using-data-driven/m-p/583637#M45765</guid>
      <dc:creator>JeffBarrette</dc:creator>
      <dc:date>2012-05-01T14:01:39Z</dc:date>
    </item>
  </channel>
</rss>

