<?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: iterate rows and export to pdf in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/iterate-rows-and-export-to-pdf/m-p/2807#M241</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Have you looked at &lt;/SPAN&gt;&lt;A href="http://resources.arcgis.com/en/help/main/10.2/index.html#//00s90000003m000000"&gt;Data Driven Pages&lt;/A&gt;&lt;SPAN&gt;?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 08 Apr 2014 17:03:37 GMT</pubDate>
    <dc:creator>MathewCoyle</dc:creator>
    <dc:date>2014-04-08T17:03:37Z</dc:date>
    <item>
      <title>iterate rows and export to pdf</title>
      <link>https://community.esri.com/t5/python-questions/iterate-rows-and-export-to-pdf/m-p/2804#M238</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I am trying to write a code that will iterate through a table, and export each row in the table as a separate PDF. The first time through the loop works. The second time around it gives me the following error message: &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Runtime error&amp;nbsp; Traceback (most recent call last):&amp;nbsp;&amp;nbsp; File "&amp;lt;string&amp;gt;", line 21, in &amp;lt;module&amp;gt;&amp;nbsp;&amp;nbsp; File "c:\program files (x86)\arcgis\desktop10.1\arcpy\arcpy\analysis.py", line 98, in Select&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; raise e ExecuteError: ERROR 000732: Input Features: Dataset Congressional_District_7 does not exist or is not supported&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I am using ArcGIS desktop 10.1&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This is the python code, I have also attached a copy:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;import arcpy from arcpy import analysis, env, management&amp;nbsp; workspace = arcpy.env.workspace = "Y:/Office2/WDIA Mapping/April/Scratch.gdb" #fill in the path for the workspace env.overwriteOutput = True&amp;nbsp; mxd = arcpy.mapping.MapDocument("CURRENT") df = arcpy.mapping.ListDataFrames(mxd, "Layers")[0]&amp;nbsp; distRows = arcpy.SearchCursor('us_house') #sets the search cursor. This may be the problem? #Try an update cursor to resolve looping problem?&amp;nbsp; for row in distRows: &amp;nbsp;&amp;nbsp;&amp;nbsp; distName = row.getValue("NAMELSAD") &amp;nbsp;&amp;nbsp;&amp;nbsp; df.extent = row.SHAPE.extent &amp;nbsp;&amp;nbsp;&amp;nbsp; df.scale = df.scale * 1.07 &amp;nbsp;&amp;nbsp;&amp;nbsp; unique_name = arcpy.CreateUniqueName(distName) &amp;nbsp;&amp;nbsp;&amp;nbsp; whereClause = "NAMELSAD &amp;lt;&amp;gt; '%s'" % distName #this results in the shadow &amp;nbsp;&amp;nbsp;&amp;nbsp; selected_dist = analysis.Select(distName, unique_name, whereClause) #shadow applied to layer &amp;nbsp;&amp;nbsp;&amp;nbsp; layerList = arcpy.mapping.ListLayers(mxd, "", df) &amp;nbsp;&amp;nbsp;&amp;nbsp; #apply the symbology to the currentShadow layer &amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.ApplySymbologyFromLayer_management (layerList[0], 'usHouseDist_05_shadow') &amp;nbsp;&amp;nbsp;&amp;nbsp; title = arcpy.mapping.ListLayoutElements(mxd, "TEXT_ELEMENT", "*")[0] &amp;nbsp;&amp;nbsp;&amp;nbsp; title.text = "trial run" #this is where we need to format the title so it can be dymanyic &amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.mapping.ExportToPDF(mxd, "Y:/Office2/WDIA Mapping/April/firstTrial/district_'%s'" % distName) #remember to fix this line &amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.mapping.RemoveLayer(df, layerList[0]) &amp;nbsp;&amp;nbsp;&amp;nbsp; del distName, unique_name &amp;nbsp;&amp;nbsp;&amp;nbsp; distRows.next() &amp;nbsp;&amp;nbsp;&amp;nbsp; #arcpy.RefreshActiveView() &lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 07 Apr 2014 17:41:46 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/iterate-rows-and-export-to-pdf/m-p/2804#M238</guid>
      <dc:creator>BradSwanson</dc:creator>
      <dc:date>2014-04-07T17:41:46Z</dc:date>
    </item>
    <item>
      <title>Re: iterate rows and export to pdf</title>
      <link>https://community.esri.com/t5/python-questions/iterate-rows-and-export-to-pdf/m-p/2805#M239</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import arcpy
from arcpy import analysis, env, management

workspace = arcpy.env.workspace = "Y:/Office2/WDIA Mapping/April/Scratch.gdb" #fill in the path for the workspace
env.overwriteOutput = True

mxd = arcpy.mapping.MapDocument("CURRENT")
df = arcpy.mapping.ListDataFrames(mxd, "Layers")[0]

distRows = arcpy.SearchCursor('us_house') #sets the search cursor. This may be the problem?
#Try an update cursor to resolve looping problem?

for row in distRows:
distName = row.getValue("NAMELSAD")
df.extent = row.SHAPE.extent
df.scale = df.scale * 1.07
unique_name = arcpy.CreateUniqueName(distName)
whereClause = "NAMELSAD &amp;lt;&amp;gt; '%s'" % distName #this results in the shadow
selected_dist = analysis.Select(distName, unique_name, whereClause) #shadow applied to this layer
layerList = arcpy.mapping.ListLayers(mxd, "", df)
#apply the symbology to the currentShadow layer
arcpy.ApplySymbologyFromLayer_management (layerList[0], 'usHouseDist_05_shadow') #whatever the top layer is
title = arcpy.mapping.ListLayoutElements(mxd, "TEXT_ELEMENT", "*")[0]
title.text = "trial run" #this is where we need to format the title so it can be dymanyic
arcpy.mapping.ExportToPDF(mxd, "Y:/Office2/WDIA Mapping/April/firstTrial/district_'%s'" % distName) #remember to fix this line
arcpy.mapping.RemoveLayer(df, layerList[0])
del distName, unique_name
distRows.next()
#arcpy.RefreshActiveView() &lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Dec 2021 20:07:26 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/iterate-rows-and-export-to-pdf/m-p/2805#M239</guid>
      <dc:creator>BradSwanson</dc:creator>
      <dc:date>2021-12-10T20:07:26Z</dc:date>
    </item>
    <item>
      <title>Re: iterate rows and export to pdf</title>
      <link>https://community.esri.com/t5/python-questions/iterate-rows-and-export-to-pdf/m-p/2806#M240</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;If I understand you are trying to iterate through a feature class and create a map for each feature with the feature name as the title? I just use a definition query:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;import arcpy&amp;nbsp; arcpy.env.overwriteOutput = True&amp;nbsp; mxd = arcpy.mapping.MapDocument(r"U:\Projects\Polygons\Polygons.mxd") df = arcpy.mapping.ListDataFrames(mxd, "Layers")[0] layer = arcpy.mapping.ListLayers(mxd, "Polygons")[0] sc = set(r[0] for r in arcpy.da.SearchCursor(layer, "Field1"))&amp;nbsp; for s in sc: &amp;nbsp;&amp;nbsp;&amp;nbsp; where_clause = "Field1 = '"+s+"'" &amp;nbsp;&amp;nbsp;&amp;nbsp; layer.definitionQuery = where_clause &amp;nbsp;&amp;nbsp;&amp;nbsp; title = arcpy.mapping.ListLayoutElements(mxd, "TEXT_ELEMENT")[0] &amp;nbsp;&amp;nbsp;&amp;nbsp; title.title = s &amp;nbsp;&amp;nbsp;&amp;nbsp; ext = layer.getExtent() &amp;nbsp;&amp;nbsp;&amp;nbsp; df.extent = ext &amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddMessage("Making H:/TestExports/FD" + s + ".pdf") &amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.mapping.ExportToPDF(mxd, "H:/TestExports/FD" + s + ".pdf")&amp;nbsp; del mxd, df, layer, sc, s&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 07 Apr 2014 23:01:52 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/iterate-rows-and-export-to-pdf/m-p/2806#M240</guid>
      <dc:creator>AmyKlug</dc:creator>
      <dc:date>2014-04-07T23:01:52Z</dc:date>
    </item>
    <item>
      <title>Re: iterate rows and export to pdf</title>
      <link>https://community.esri.com/t5/python-questions/iterate-rows-and-export-to-pdf/m-p/2807#M241</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Have you looked at &lt;/SPAN&gt;&lt;A href="http://resources.arcgis.com/en/help/main/10.2/index.html#//00s90000003m000000"&gt;Data Driven Pages&lt;/A&gt;&lt;SPAN&gt;?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 08 Apr 2014 17:03:37 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/iterate-rows-and-export-to-pdf/m-p/2807#M241</guid>
      <dc:creator>MathewCoyle</dc:creator>
      <dc:date>2014-04-08T17:03:37Z</dc:date>
    </item>
    <item>
      <title>Re: iterate rows and export to pdf</title>
      <link>https://community.esri.com/t5/python-questions/iterate-rows-and-export-to-pdf/m-p/2808#M242</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thank you Amy Klug! The definition query worked! I have looked into data driven pages. I think that is the next step in the project. Thanks again!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 08 Apr 2014 17:20:13 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/iterate-rows-and-export-to-pdf/m-p/2808#M242</guid>
      <dc:creator>BradSwanson</dc:creator>
      <dc:date>2014-04-08T17:20:13Z</dc:date>
    </item>
  </channel>
</rss>

