<?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: Where can I go to find someone to review a lengthy python script in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/where-can-i-go-to-find-someone-to-review-a-lengthy/m-p/186772#M14355</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The script is very lengthy, over 700 lines of code and performs several analyses using several modules including arcpy, zipfile, win32com.client, glob, shutil, os.path, and OrderedDict from collections . It will be run on computers that have ArcGIS 10.2.1 advanced licenses.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I pared it down to just the commands I use and a few of the commands in the more complex functions (see below). Right now the script runs in immediate mode but I would like to be able to run it as a stand-alone script.&amp;nbsp; My main concerns are the commands that manipulate the TOC, legend properties, and those exporting these as pdf files.Note: Incomplete code. This is just a sampling of the commands that may not run as stand-alone.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;#Arcpy Commmands that are used in script&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;arcpy.Buffer_analysis&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;arcpy.CopyRows_management&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;arcpy.CreateFileGDB_management&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;arcpy.da.SearchCursor&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; append(row[0])&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;arcpy.DeleteRows_management&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;arcpy.Delete_managementarcpy.Delete_management&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;arcpy.Describe(CompanySite).shapeType&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;arcpy.Dissolve_management&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;arcpy.Frequency_analysis&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;arcpy.GetParameterAsText(0)&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;arcpy.ListFields&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;arcpy.MakeFeatureLayer_management&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;arcpy.MakeTableView_management&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;arcpy.mapping.ListLayers(mxd, "Company Locations")[0]&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Lyr.visible = True&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;arcpy.mapping.ListLayoutElements&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; scaleBar.elementPositionX&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;arcpy.Polygon(arcpy.Array([df.extent.lowerLeft, df.extent.lowerRight, df.extent.upperRight, df.extent.upperLeft]), df.spatialReference)&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;arcpy.RefreshActiveView()&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;arcpy.SelectLayerByLocation_management&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;arcpy.Sort_management&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;arcpy.Statistics_analysis&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;arcpy.TableToDBASE_conversion&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;arcpy.TabulateIntersection_analysis&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;arcpy.env.overwriteOutput&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;arcpy.mapping.ExportToPDF&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;arcpy.mapping.Layer&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;arcpy.mapping.ListLayers&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;arcpy.mapping.RemoveLayer(df, lyr)&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;int(arcpy.GetCount_management)&lt;/P&gt;&lt;P&gt;# Setting up group layer and adding shapefiles to it. Setting order, renaming shapefiles, and visibility in&lt;/P&gt;&lt;P&gt;# TOC also happens below to export series of pdf maps&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;arcpy.mapping.Layer(CompanySite)&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;CompanySite_lyr.name = "Company Location"&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;arcpy.mapping.UpdateLayer(df,CompanySite_lyr, sourceLayer)&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;groupLayer = arcpy.mapping.Layer&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;groupLayer.name = "Company Locations"&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;arcpy.mapping.AddLayer&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;arcpy.mapping.AddLayerToGroup&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;df.extent&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;df.scale&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;title = arcpy.mapping.ListLayoutElements(mxd, "TEXT_ELEMENT", "MAPTITLE")[0]&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;title.text = CompanySite + "\n" + mapFile&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;mxd = arcpy.mapping.MapDocument("CURRENT")&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;df = arcpy.mapping.ListDataFrames(mxd, "Layers")[0]&lt;/P&gt;&lt;P&gt;# Other non arcpy commands used in script&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;os.path.splitext&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;while os.path.exists&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; shutil.rmtree&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;os.makedirs&lt;/P&gt;&lt;P&gt;# this is run in a function after buffer analysis results&lt;/P&gt;&lt;P&gt;run_excel_macros&lt;/P&gt;&lt;P&gt;# opens dbf output in excel and formats excel files to import into word document.&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;xlApp = win32com.client.DispatchEx('Excel.Application')&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;xlsPath = os.path.expanduser&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;wb = xlApp.Workbooks.Open(Filename=xlsPath)&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;wb.Application.DisplayAlerts = False&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;xlApp.Run&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;wb.Close&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;xlApp.Quit()&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;xlApp = None&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;zipfile.ZipFile("D:\\Templates\\wordTemplate.docx")&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;report = zipfile.ZipFile(myDir + "\\Report.docx", "a")&lt;/P&gt;&lt;P&gt;# This section takes the variables derived from analyses and modified text based on results and&lt;/P&gt;&lt;P&gt;# replaces it with variables imbedded in Word template: Commands used to do this are as follows:&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;with open(template.extract("word/document.xml", myDir + "\\")) as tempXmlFile:&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; tempXml = tempXmlFile.read()&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;for key in replaceText.keys():&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; tempXml = tempXml.replace(str(key), str(replaceText.get(key)))&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;with open(myDir + "\\temp.xml", "w+") as tempXmlFile:&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; tempXmlFile.write(tempXml)&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;for file in template.filelist:&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if not file.filename == "word/document.xml":&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; report.writestr(file.filename, template.read(file))&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;report.write(rmyDir + "\\temp.xml", "word/document.xml")&lt;/P&gt;&lt;P&gt;# Runs word macro to format Word document and import excel tables&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;word = win32com.client.Dispatch('Word.Application')&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;doc = word.Documents.Open(myDir + "\\Report.docx")&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;word.Run("formattingMacros")&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;/P&gt;&lt;P&gt;Any and all guidance greatly appreciated.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 11 Dec 2014 18:48:23 GMT</pubDate>
    <dc:creator>BrendaJameson</dc:creator>
    <dc:date>2014-12-11T18:48:23Z</dc:date>
    <item>
      <title>Where can I go to find someone to review a lengthy python script</title>
      <link>https://community.esri.com/t5/python-questions/where-can-i-go-to-find-someone-to-review-a-lengthy/m-p/186768#M14351</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I would like to rewrite a script that is executed in ArcMap as a standalone script. I was told it cannot be done as some of the commands are only available in ArcMap. I am fairly new to both languages and am at a loss as to where to go from here. I was hoping there was a place or person who does this kind of thing for a very nominal fee (I am on a very tight budget-my own personal expense, not a company's). I would not need it to be rewritten but pointers would help.I would like to send them the script and have them assess the effort and possibly give me a few pointers to get me going in the right direction.I am sorry if this is not the right forum. I just don't know where else to get the help. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;To facilitate this as a discussion, perhaps the old python/GIS gurus could let us newbies know of the different forums out there and the purposes of each. Maybe there is a place where seasoned programmers are available to offer this kind of assistance.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks in advance.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 11 Dec 2014 04:34:21 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/where-can-i-go-to-find-someone-to-review-a-lengthy/m-p/186768#M14351</guid>
      <dc:creator>BrendaJameson</dc:creator>
      <dc:date>2014-12-11T04:34:21Z</dc:date>
    </item>
    <item>
      <title>Re: Where can I go to find someone to review a lengthy python script</title>
      <link>https://community.esri.com/t5/python-questions/where-can-i-go-to-find-someone-to-review-a-lengthy/m-p/186769#M14352</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;SPAN style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;I would like to rewrite a script that is executed in ArcMap as a standalone script. I was told it cannot be done as some of the commands are only available in ArcMap.&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;Do you intend on running the script as a standalone script on a machine that has ArcGIS installed? - if so this is possible as you can access ArcGIS functions via the arcpy package.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;If you want to run the script outside of ArcGIS then there are likely issues - most notably ESRI licensing restrictions.&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 11 Dec 2014 04:53:49 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/where-can-i-go-to-find-someone-to-review-a-lengthy/m-p/186769#M14352</guid>
      <dc:creator>OwenEarley</dc:creator>
      <dc:date>2014-12-11T04:53:49Z</dc:date>
    </item>
    <item>
      <title>Re: Where can I go to find someone to review a lengthy python script</title>
      <link>https://community.esri.com/t5/python-questions/where-can-i-go-to-find-someone-to-review-a-lengthy/m-p/186770#M14353</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;"&lt;EM&gt;I was told it cannot be done as some of the commands are only available in ArcMap&lt;/EM&gt;."&lt;/P&gt;&lt;P&gt;Just about everything is available through python / arcpy. So who is telling you this? Sure if you want to write customized interfaces, web stuff etc, then you need .Net, ArcObjects and all that.&lt;/P&gt;&lt;P&gt;Tell us what you want to do, what progress you have made so far etc. There is lots of arcpy / python snippets, help out there.&lt;/P&gt;&lt;P&gt;I am sure that the python fundies here or at GIS-SE will help with particular questions.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 11 Dec 2014 06:07:57 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/where-can-i-go-to-find-someone-to-review-a-lengthy/m-p/186770#M14353</guid>
      <dc:creator>NeilAyres</dc:creator>
      <dc:date>2014-12-11T06:07:57Z</dc:date>
    </item>
    <item>
      <title>Re: Where can I go to find someone to review a lengthy python script</title>
      <link>https://community.esri.com/t5/python-questions/where-can-i-go-to-find-someone-to-review-a-lengthy/m-p/186771#M14354</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;What version of ArcMap are you using?&amp;nbsp; This is quite important.&lt;/P&gt;&lt;P&gt;Lengthy is relative... how many lines of code are you talking about.&lt;/P&gt;&lt;P&gt;Are you using any non-standard python libraries?&amp;nbsp; (simply copy and past any "import blah blah" lines here)&lt;/P&gt;&lt;P&gt;There is always someone around that is bored and/or in full procrastinating mode so ...&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 11 Dec 2014 07:53:54 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/where-can-i-go-to-find-someone-to-review-a-lengthy/m-p/186771#M14354</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2014-12-11T07:53:54Z</dc:date>
    </item>
    <item>
      <title>Re: Where can I go to find someone to review a lengthy python script</title>
      <link>https://community.esri.com/t5/python-questions/where-can-i-go-to-find-someone-to-review-a-lengthy/m-p/186772#M14355</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The script is very lengthy, over 700 lines of code and performs several analyses using several modules including arcpy, zipfile, win32com.client, glob, shutil, os.path, and OrderedDict from collections . It will be run on computers that have ArcGIS 10.2.1 advanced licenses.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I pared it down to just the commands I use and a few of the commands in the more complex functions (see below). Right now the script runs in immediate mode but I would like to be able to run it as a stand-alone script.&amp;nbsp; My main concerns are the commands that manipulate the TOC, legend properties, and those exporting these as pdf files.Note: Incomplete code. This is just a sampling of the commands that may not run as stand-alone.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;#Arcpy Commmands that are used in script&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;arcpy.Buffer_analysis&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;arcpy.CopyRows_management&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;arcpy.CreateFileGDB_management&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;arcpy.da.SearchCursor&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; append(row[0])&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;arcpy.DeleteRows_management&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;arcpy.Delete_managementarcpy.Delete_management&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;arcpy.Describe(CompanySite).shapeType&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;arcpy.Dissolve_management&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;arcpy.Frequency_analysis&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;arcpy.GetParameterAsText(0)&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;arcpy.ListFields&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;arcpy.MakeFeatureLayer_management&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;arcpy.MakeTableView_management&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;arcpy.mapping.ListLayers(mxd, "Company Locations")[0]&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Lyr.visible = True&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;arcpy.mapping.ListLayoutElements&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; scaleBar.elementPositionX&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;arcpy.Polygon(arcpy.Array([df.extent.lowerLeft, df.extent.lowerRight, df.extent.upperRight, df.extent.upperLeft]), df.spatialReference)&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;arcpy.RefreshActiveView()&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;arcpy.SelectLayerByLocation_management&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;arcpy.Sort_management&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;arcpy.Statistics_analysis&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;arcpy.TableToDBASE_conversion&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;arcpy.TabulateIntersection_analysis&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;arcpy.env.overwriteOutput&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;arcpy.mapping.ExportToPDF&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;arcpy.mapping.Layer&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;arcpy.mapping.ListLayers&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;arcpy.mapping.RemoveLayer(df, lyr)&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;int(arcpy.GetCount_management)&lt;/P&gt;&lt;P&gt;# Setting up group layer and adding shapefiles to it. Setting order, renaming shapefiles, and visibility in&lt;/P&gt;&lt;P&gt;# TOC also happens below to export series of pdf maps&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;arcpy.mapping.Layer(CompanySite)&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;CompanySite_lyr.name = "Company Location"&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;arcpy.mapping.UpdateLayer(df,CompanySite_lyr, sourceLayer)&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;groupLayer = arcpy.mapping.Layer&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;groupLayer.name = "Company Locations"&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;arcpy.mapping.AddLayer&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;arcpy.mapping.AddLayerToGroup&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;df.extent&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;df.scale&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;title = arcpy.mapping.ListLayoutElements(mxd, "TEXT_ELEMENT", "MAPTITLE")[0]&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;title.text = CompanySite + "\n" + mapFile&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;mxd = arcpy.mapping.MapDocument("CURRENT")&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;df = arcpy.mapping.ListDataFrames(mxd, "Layers")[0]&lt;/P&gt;&lt;P&gt;# Other non arcpy commands used in script&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;os.path.splitext&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;while os.path.exists&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; shutil.rmtree&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;os.makedirs&lt;/P&gt;&lt;P&gt;# this is run in a function after buffer analysis results&lt;/P&gt;&lt;P&gt;run_excel_macros&lt;/P&gt;&lt;P&gt;# opens dbf output in excel and formats excel files to import into word document.&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;xlApp = win32com.client.DispatchEx('Excel.Application')&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;xlsPath = os.path.expanduser&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;wb = xlApp.Workbooks.Open(Filename=xlsPath)&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;wb.Application.DisplayAlerts = False&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;xlApp.Run&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;wb.Close&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;xlApp.Quit()&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;xlApp = None&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;zipfile.ZipFile("D:\\Templates\\wordTemplate.docx")&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;report = zipfile.ZipFile(myDir + "\\Report.docx", "a")&lt;/P&gt;&lt;P&gt;# This section takes the variables derived from analyses and modified text based on results and&lt;/P&gt;&lt;P&gt;# replaces it with variables imbedded in Word template: Commands used to do this are as follows:&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;with open(template.extract("word/document.xml", myDir + "\\")) as tempXmlFile:&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; tempXml = tempXmlFile.read()&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;for key in replaceText.keys():&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; tempXml = tempXml.replace(str(key), str(replaceText.get(key)))&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;with open(myDir + "\\temp.xml", "w+") as tempXmlFile:&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; tempXmlFile.write(tempXml)&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;for file in template.filelist:&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if not file.filename == "word/document.xml":&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; report.writestr(file.filename, template.read(file))&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;report.write(rmyDir + "\\temp.xml", "word/document.xml")&lt;/P&gt;&lt;P&gt;# Runs word macro to format Word document and import excel tables&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;word = win32com.client.Dispatch('Word.Application')&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;doc = word.Documents.Open(myDir + "\\Report.docx")&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;word.Run("formattingMacros")&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;/P&gt;&lt;P&gt;Any and all guidance greatly appreciated.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 11 Dec 2014 18:48:23 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/where-can-i-go-to-find-someone-to-review-a-lengthy/m-p/186772#M14355</guid>
      <dc:creator>BrendaJameson</dc:creator>
      <dc:date>2014-12-11T18:48:23Z</dc:date>
    </item>
    <item>
      <title>Re: Where can I go to find someone to review a lengthy python script</title>
      <link>https://community.esri.com/t5/python-questions/where-can-i-go-to-find-someone-to-review-a-lengthy/m-p/186773#M14356</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Brenda&lt;BR /&gt;It would be better to list the functions in chronological order to see where the break where the arcpy.mapping begins and ends and all the excel word zippy thing fits in.&amp;nbsp;&amp;nbsp; &lt;BR /&gt;Many of the functions like buffering don't need to have Arcmap open at all and as long as you maintain a list of the things created you can call upon them for future work.&lt;/P&gt;&lt;P&gt;When it comes to arcpy.mapping you have to be careful since you are probably working with the Current mxd and the Current dataframe etc etc.&amp;nbsp; This can largely be circumvented by creating an mxd on the fly by having a template project residing in the same or easily locatable folder relative to the location of the running script&amp;nbsp; (remember&amp;nbsp; sys.argv[0] is the name of the running script from which you can parse off the path and append an existing mxd name to it ).&amp;nbsp; Your template may be constructed anyway you want to facilitate and minimize the code.&amp;nbsp; For instance the whole block of functionality after this line...&lt;/P&gt;&lt;P&gt;# TOC also happens below to export series of pdf maps&lt;/P&gt;&lt;P&gt;could be minimized if a template mxd was created and all you would have to do is add data to it.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you must run the whole thing at once, then you may have to put in time delays (time.sleep) to ensure that outputs are created before they become inputs to other events.&amp;nbsp; In short...it seems like you have a handle on things.&amp;nbsp; You can get really fancy and break up your script into several scripts which are then imported into a main script and information is passed back and forth between them as needed.&amp;nbsp; For instance all the excel word zip stuff I would have as a separate import module, in that way I can test it separately and completely ignore it if I want.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;As a practical example...I wrote a Crosstabulation/Kappa Statistics toolbox which has a main script called:&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;CrossTabulateStatistics.py&lt;/STRONG&gt;&amp;nbsp;&amp;nbsp; -&amp;nbsp; called by the *.tbx&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; in there I use system and other imports&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;#Import the basic modules&lt;BR /&gt;import os, sys, string&amp;nbsp; &lt;/P&gt;&lt;P&gt;import arcpy&lt;BR /&gt;&lt;STRONG&gt;import crosstab as CT&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;crosstab&lt;/STRONG&gt; is a script that I wrote to compartmentalize many functions.&amp;nbsp; It has an import section as well&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;import math&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;import Distributions as d&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;import copy&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Distributions&lt;/STRONG&gt; is another script I wrote that cobbled together various distribution functions over the web.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;so when the main script runs from the toolbox, all the previous modules (aka scripts) are used.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I also produced another script for the toolbox called &lt;STRONG&gt;PrepareData.py &lt;/STRONG&gt;which does all the data preparation ahead of time.&amp;nbsp;&amp;nbsp; I could have incorporated everything into one script to run as a standalone script but I would have had to rename the whole thing &lt;STRONG&gt;Magic-O-rama&lt;/STRONG&gt;&amp;nbsp; &lt;IMG src="https://community.esri.com/legacyfs/online/emoticons/happy.png" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 11 Dec 2014 19:50:49 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/where-can-i-go-to-find-someone-to-review-a-lengthy/m-p/186773#M14356</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2014-12-11T19:50:49Z</dc:date>
    </item>
    <item>
      <title>Re: Where can I go to find someone to review a lengthy python script</title>
      <link>https://community.esri.com/t5/python-questions/where-can-i-go-to-find-someone-to-review-a-lengthy/m-p/186774#M14357</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I do have a template which I rename and run the script from. I realize that the geoprocessing commands such as buffering can be run as a stand alone but am under the impression that some of the actions performed with arcpy.mapping cannot (such as manipulating the layer properties in the TOC to export as pdf files, moving elements around in layout based upon map extents, turning on and off layer visibilities, etc.) &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I do not have the authority to post the script online but I am think I can send to one or people to review and let me know the basic scope of work required to make this a stand alone (or even a more 'tight' script) which is why in my original post I asked if there was some place I could go (or someone who was willing to help) to get this assessment done. Unfortunately the cost of getting the assessment done is on me and I am a lowly, underpaid employee (as I am sure most of us are these days.)&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 15 Dec 2014 18:27:06 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/where-can-i-go-to-find-someone-to-review-a-lengthy/m-p/186774#M14357</guid>
      <dc:creator>BrendaJameson</dc:creator>
      <dc:date>2014-12-15T18:27:06Z</dc:date>
    </item>
    <item>
      <title>Re: Where can I go to find someone to review a lengthy python script</title>
      <link>https://community.esri.com/t5/python-questions/where-can-i-go-to-find-someone-to-review-a-lengthy/m-p/186775#M14358</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Brenda... Sorry I know of no such place ... hope someone can pick it up as project ... I have to finish term marking and prep work for courses in January... best of luck&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 15 Dec 2014 19:19:36 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/where-can-i-go-to-find-someone-to-review-a-lengthy/m-p/186775#M14358</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2014-12-15T19:19:36Z</dc:date>
    </item>
    <item>
      <title>Re: Where can I go to find someone to review a lengthy python script</title>
      <link>https://community.esri.com/t5/python-questions/where-can-i-go-to-find-someone-to-review-a-lengthy/m-p/186776#M14359</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The only thing I see from the listed command that won't work as a stand-alone script is the line:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="python" __jive_macro_name="code" class="jive_macro_code jive_text_macro _jivemacro_uid_14186999018446735" jivemacro_uid="_14186999018446735"&gt;&lt;P&gt;mxd = arcpy.mapping.MapDocument("CURRENT")&lt;/P&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The CURRENT keyword is not valid in a standalone script. Replacing this with a path to the MXD you want to you should not be a problem.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If someone is going to revise the script, you should provide this person the data used in the process, the MXD, the Excel and Word templates including the macro's, etc.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 16 Dec 2014 03:21:10 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/where-can-i-go-to-find-someone-to-review-a-lengthy/m-p/186776#M14359</guid>
      <dc:creator>XanderBakker</dc:creator>
      <dc:date>2014-12-16T03:21:10Z</dc:date>
    </item>
    <item>
      <title>Re: Where can I go to find someone to review a lengthy python script</title>
      <link>https://community.esri.com/t5/python-questions/where-can-i-go-to-find-someone-to-review-a-lengthy/m-p/186777#M14360</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have a burning question... why do you want to convert the script to a stand alone script? What are you trying to gain from this? Is it a something you want to execute as a scheduled task?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 16 Dec 2014 12:11:01 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/where-can-i-go-to-find-someone-to-review-a-lengthy/m-p/186777#M14360</guid>
      <dc:creator>XanderBakker</dc:creator>
      <dc:date>2014-12-16T12:11:01Z</dc:date>
    </item>
    <item>
      <title>Re: Where can I go to find someone to review a lengthy python script</title>
      <link>https://community.esri.com/t5/python-questions/where-can-i-go-to-find-someone-to-review-a-lengthy/m-p/186778#M14361</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Not sure I have a good answer for that other than it was requested and I thought it would be a good learning experience. I do like the idea of compartmentalizing sections of the script and calling them as needed. It would make testing the script faster when the code in question is towards the end of the process. Dan Patterson gave me some great suggestions. Now I just have to hunt down some sample scripts to help guide me along.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 18 Dec 2014 23:03:24 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/where-can-i-go-to-find-someone-to-review-a-lengthy/m-p/186778#M14361</guid>
      <dc:creator>BrendaJameson</dc:creator>
      <dc:date>2014-12-18T23:03:24Z</dc:date>
    </item>
    <item>
      <title>Re: Where can I go to find someone to review a lengthy python script</title>
      <link>https://community.esri.com/t5/python-questions/where-can-i-go-to-find-someone-to-review-a-lengthy/m-p/186779#M14362</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Maybe this post can help you in some way: &lt;A href="https://community.esri.com/docs/DOC-1927"&gt;Some Python Snippets&lt;/A&gt; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you have more specific problems you run into, just post them, and there will be loads of people eager to help you (for free),.. that's what the community is all about.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Kind regards, Xander&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 18 Dec 2014 23:48:05 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/where-can-i-go-to-find-someone-to-review-a-lengthy/m-p/186779#M14362</guid>
      <dc:creator>XanderBakker</dc:creator>
      <dc:date>2014-12-18T23:48:05Z</dc:date>
    </item>
  </channel>
</rss>

