<?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: SetParameterAsText To View Python Tool Results in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/setparameterastext-to-view-python-tool-results/m-p/580700#M45538</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;for example your line&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;print row [4] + " " + featureclass&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;could be&lt;/P&gt;&lt;P&gt;msg = row[4] + " " + featureclass&lt;/P&gt;&lt;P&gt;print(msg)&lt;/P&gt;&lt;P&gt;arcpy.AddMessage(msg)&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 08 Jun 2016 22:12:46 GMT</pubDate>
    <dc:creator>DanPatterson_Retired</dc:creator>
    <dc:date>2016-06-08T22:12:46Z</dc:date>
    <item>
      <title>SetParameterAsText To View Python Tool Results</title>
      <link>https://community.esri.com/t5/python-questions/setparameterastext-to-view-python-tool-results/m-p/580697#M45535</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have the following which I can successfully get my desired results with the input prompt standalone script.&amp;nbsp; Yet, I prefer that a tool I created to be used and display the results. What am I missing in order to view the results?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;#Import Modules
import csv,os,arcpy

#Set variables
ifile&amp;nbsp; = open('PythonShellSave.csv','r')
reader = csv.reader(ifile)
featureclass = input("Name of the feature class ? ")
#featureclass = arcpy.GetParameterAsText(0)
 
#Set path location of Excel (CSV) file 
path = 'C:\WriteMxdInfoToExcel'
os.chdir(path)

#CSV Module terminology row is horizontal &amp;amp; field is vertical;column is horizontal &amp;amp; row is vertical for excel.
for row in reader:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for field in row:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if field == featureclass:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print row [4] + " " + featureclass
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
arcpy.SetParameterAsText(1,row)

#Close Excel (CSV) file
ifile.close()&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 00:58:20 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/setparameterastext-to-view-python-tool-results/m-p/580697#M45535</guid>
      <dc:creator>DevinUnderwood2</dc:creator>
      <dc:date>2021-12-12T00:58:20Z</dc:date>
    </item>
    <item>
      <title>Re: SetParameterAsText To View Python Tool Results</title>
      <link>https://community.esri.com/t5/python-questions/setparameterastext-to-view-python-tool-results/m-p/580698#M45536</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;are you wanting to see the equivalent of a print statement within arcmap? &lt;/P&gt;&lt;P&gt;if so &lt;A href="http://desktop.arcgis.com/en/arcmap/latest/analyze/arcpy-functions/addmessage.htm" title="http://desktop.arcgis.com/en/arcmap/latest/analyze/arcpy-functions/addmessage.htm"&gt;AddMessage—Help | ArcGIS for Desktop&lt;/A&gt; &lt;/P&gt;&lt;P&gt;you may find it easier to accumulate messages then just include 2 lines so you can 'print' witnin and out arcmap&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;.....&lt;/P&gt;&lt;P&gt;msg += "more stuff"&lt;/P&gt;&lt;P&gt;arcpy.AddMessage(msg)&amp;nbsp; # for inside arcmap&lt;/P&gt;&lt;P&gt;print(msg)&amp;nbsp; # python 2 and 3 compliant&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 08 Jun 2016 22:00:16 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/setparameterastext-to-view-python-tool-results/m-p/580698#M45536</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2016-06-08T22:00:16Z</dc:date>
    </item>
    <item>
      <title>Re: SetParameterAsText To View Python Tool Results</title>
      <link>https://community.esri.com/t5/python-questions/setparameterastext-to-view-python-tool-results/m-p/580699#M45537</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yes equivalent of a print statement within arcmap.&lt;/P&gt;&lt;P&gt;I just want to view results.&lt;/P&gt;&lt;P&gt;I will take a look about AddMessage, thank you.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 08 Jun 2016 22:03:36 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/setparameterastext-to-view-python-tool-results/m-p/580699#M45537</guid>
      <dc:creator>DevinUnderwood2</dc:creator>
      <dc:date>2016-06-08T22:03:36Z</dc:date>
    </item>
    <item>
      <title>Re: SetParameterAsText To View Python Tool Results</title>
      <link>https://community.esri.com/t5/python-questions/setparameterastext-to-view-python-tool-results/m-p/580700#M45538</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;for example your line&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;print row [4] + " " + featureclass&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;could be&lt;/P&gt;&lt;P&gt;msg = row[4] + " " + featureclass&lt;/P&gt;&lt;P&gt;print(msg)&lt;/P&gt;&lt;P&gt;arcpy.AddMessage(msg)&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 08 Jun 2016 22:12:46 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/setparameterastext-to-view-python-tool-results/m-p/580700#M45538</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2016-06-08T22:12:46Z</dc:date>
    </item>
    <item>
      <title>Re: SetParameterAsText To View Python Tool Results</title>
      <link>https://community.esri.com/t5/python-questions/setparameterastext-to-view-python-tool-results/m-p/580701#M45539</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If you want something more generic with a time stamp&amp;nbsp; (sorry about the %formatting instead of the {} .format style...haven't updated it for a while)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import time
import arcpy

def timeStamp():
&amp;nbsp;&amp;nbsp;&amp;nbsp; """
&amp;nbsp;&amp;nbsp;&amp;nbsp; returns time stamp.
&amp;nbsp;&amp;nbsp;&amp;nbsp; """
&amp;nbsp;&amp;nbsp;&amp;nbsp; return time.strftime(' --&amp;nbsp; %B %d - %H:%M:%S')

def myMsgs(message):
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddMessage(message + ' %s' %(timeStamp()))
&amp;nbsp;&amp;nbsp;&amp;nbsp; print(message)&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # + ' %s' %(timeStamp()))&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;then if you enter&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;myMsgs("you message here with whatever formatting {0}".format(variableToFormat))&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;the myMsgs will work in either without having to add both lines.&amp;nbsp; works for me (in my_utils.py file) but it is a pain when I have to share my code on the forums.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 00:58:22 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/setparameterastext-to-view-python-tool-results/m-p/580701#M45539</guid>
      <dc:creator>RebeccaStrauch__GISP</dc:creator>
      <dc:date>2021-12-12T00:58:22Z</dc:date>
    </item>
    <item>
      <title>Re: SetParameterAsText To View Python Tool Results</title>
      <link>https://community.esri.com/t5/python-questions/setparameterastext-to-view-python-tool-results/m-p/580702#M45540</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you for the input. However I am not familiar enough with the time module nor what the % means. I am not aware of .format either. As you can see I am beginner and I am just learning and attempting to properly use the Add Message, which I am still working on.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 09 Jun 2016 14:57:02 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/setparameterastext-to-view-python-tool-results/m-p/580702#M45540</guid>
      <dc:creator>DevinUnderwood2</dc:creator>
      <dc:date>2016-06-09T14:57:02Z</dc:date>
    </item>
    <item>
      <title>Re: SetParameterAsText To View Python Tool Results</title>
      <link>https://community.esri.com/t5/python-questions/setparameterastext-to-view-python-tool-results/m-p/580703#M45541</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Sorry about that Devin, I did a quick copy paste.&amp;nbsp; Here is a simpler version with the time module removed.&amp;nbsp; I just have that in there so I could get a time stamp on each message so I knew how long each process was taking...not a necessary component at all.&amp;nbsp; This sample imports arcpy, creates the simple myMsgs function and has five samples using it with the function.&amp;nbsp; This should work in the python window, or if you run it in a arcpy script (.py file).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Sample 1: just text&lt;/P&gt;&lt;P&gt;Sample 2: a variable&lt;/P&gt;&lt;P&gt;Sample 3: some text, two variables and a blank line after&amp;nbsp;&amp;nbsp;&amp;nbsp; The {#} line up with the variables in the .format( )&amp;nbsp; part.&amp;nbsp; The # isn't mandatory, but good practice and allow you to reorder or even repeat the use of a variable in the list&lt;/P&gt;&lt;P&gt;Sample 4: some text and some math with the number variable&lt;/P&gt;&lt;P&gt;Sample 5: reusing one of the variables in the list.&lt;/P&gt;&lt;P&gt;These formats work with both the print and AddMessage&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import arcpy

def myMsgs(message):&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddMessage(message)
&amp;nbsp;&amp;nbsp;&amp;nbsp; print(message)&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; 

somethingToPrint = "print this message"
aNumber = 5

myMsgs("printing just a line of text I type here")
myMsgs(somethingToPrint)
myMsgs("printing {0} with a number {1} with a blank line after \n".format(somethingToPrint, aNumber))
myMsgs("printing with a number + 1: {0} ".format(aNumber + 1))
myMsgs("{1}: printing {0} with a number {1} with a blank line after \n".format(somethingToPrint, aNumber))&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this helps&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;edit:&amp;nbsp; btw, you should check out and bookmark &lt;A href="https://community.esri.com/migrated-users/3116" target="_blank"&gt;Dan Patterson&lt;/A&gt;​ 's &lt;A href="https://community.esri.com/migration-blogpost/1167" target="_blank"&gt;Py... blog&lt;/A&gt;&amp;nbsp;&amp;nbsp; for many hints and other links.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 00:58:25 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/setparameterastext-to-view-python-tool-results/m-p/580703#M45541</guid>
      <dc:creator>RebeccaStrauch__GISP</dc:creator>
      <dc:date>2021-12-12T00:58:25Z</dc:date>
    </item>
    <item>
      <title>Re: SetParameterAsText To View Python Tool Results</title>
      <link>https://community.esri.com/t5/python-questions/setparameterastext-to-view-python-tool-results/m-p/580704#M45542</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you for taking the time to further explain.&amp;nbsp; Will this work in a script that I am using with a tool I created? To automatically display message to results?&amp;nbsp; I tested out the function but it is not automatic when run and seen in python shell. However, as mentioned, my actual goal is to use it as a tool. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I will take a look at the Blog, thanks.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 09 Jun 2016 16:44:34 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/setparameterastext-to-view-python-tool-results/m-p/580704#M45542</guid>
      <dc:creator>DevinUnderwood2</dc:creator>
      <dc:date>2016-06-09T16:44:34Z</dc:date>
    </item>
    <item>
      <title>Re: SetParameterAsText To View Python Tool Results</title>
      <link>https://community.esri.com/t5/python-questions/setparameterastext-to-view-python-tool-results/m-p/580705#M45543</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;yes, it should.&amp;nbsp; The function will know if it is in a script or in the window and print as needed, while ignoring the other.&amp;nbsp; I use this all the time since I switch between the two and it's a hassle to change and/or have both.&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Tip: if you are tying to debug but don't know where it is crashing,&amp;nbsp; you can put lots of these within your code maybe even right after each process... I many times do simple numbered statements just to see how far it gets so I can track down an issue..&lt;/P&gt;&lt;P&gt;...a process&lt;/P&gt;&lt;P&gt; myMsgs("here1)&lt;/P&gt;&lt;P&gt;..another process&lt;/P&gt;&lt;P&gt;myMsgs("here2)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Of course you would want something more meaningful for your final script,&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 09 Jun 2016 17:22:26 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/setparameterastext-to-view-python-tool-results/m-p/580705#M45543</guid>
      <dc:creator>RebeccaStrauch__GISP</dc:creator>
      <dc:date>2016-06-09T17:22:26Z</dc:date>
    </item>
    <item>
      <title>Re: SetParameterAsText To View Python Tool Results</title>
      <link>https://community.esri.com/t5/python-questions/setparameterastext-to-view-python-tool-results/m-p/580706#M45544</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am trying to have Add message for the variable, but I am having trouble calling the function with the variable.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;#Import Modules
import csv,os,arcpy,time 

#Set variables
ifile&amp;nbsp; = open('PythonShellSave.csv','r')
reader = csv.reader(ifile)
featureclass = input("Name of the feature class ? ")
#featureclass = arcpy.GetParameterAsText(0)

#Set path location of Excel (CSV) file 
path = 'C:\Users\WriteMxdInfoToExcel'
os.chdir(path)

# Create function
def myMsgs(message):&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddMessage(message)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
#CSV Module terminology row is horizontal &amp;amp; field is vertical;column is horizontal &amp;amp; row is vertical for excel
for row in reader:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for field in row:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if field == featureclass:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; final = row[4] + " " + featureclass
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print final
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; myMsgs (final)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
#Close Excel (CSV) file
ifile.close()&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 00:58:28 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/setparameterastext-to-view-python-tool-results/m-p/580706#M45544</guid>
      <dc:creator>DevinUnderwood2</dc:creator>
      <dc:date>2021-12-12T00:58:28Z</dc:date>
    </item>
    <item>
      <title>Re: SetParameterAsText To View Python Tool Results</title>
      <link>https://community.esri.com/t5/python-questions/setparameterastext-to-view-python-tool-results/m-p/580707#M45545</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;put&lt;/P&gt;&lt;P&gt;print(message)&lt;/P&gt;&lt;P&gt;inside the def after or before the adrcpy add message&lt;/P&gt;&lt;P&gt;get used to print statments using brackets is print("stuff")&amp;nbsp; get ready for python 3&lt;/P&gt;&lt;P&gt;use raw format in paths&amp;nbsp; (ie add an r&amp;nbsp; r"c:\mypath\some.txt"&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ps&lt;/P&gt;&lt;P&gt;you will get a failure if you don't 'string' stuff&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;def myMsgs(message):&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; """ a test """&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; msg = "not another message... {0}".format(message)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; print(msg)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.Addmessage(msg)&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 09 Jun 2016 17:48:57 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/setparameterastext-to-view-python-tool-results/m-p/580707#M45545</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2016-06-09T17:48:57Z</dc:date>
    </item>
    <item>
      <title>Re: SetParameterAsText To View Python Tool Results</title>
      <link>https://community.esri.com/t5/python-questions/setparameterastext-to-view-python-tool-results/m-p/580708#M45546</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;you don't need to import time since you are not using.&lt;/P&gt;&lt;P&gt;change&amp;nbsp; path = 'C:\Users\WriteMxdInfoToExcel'&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; to&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; path = r'C:\Users\WriteMxdInfoToExcel' &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; (see dan's blog on file names)&lt;/P&gt;&lt;P&gt;I would add&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.env.workspace = path&lt;/P&gt;&lt;P&gt;and remove the os.chdir(path)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;include for the arcy.AddMessage and the print in the myMsgs function or you will have to change each time.&amp;nbsp; Get used to using&amp;nbsp;&amp;nbsp; print(message) with the parans since the next version of python will require it.&amp;nbsp; Again, Dan points to some good resources for what's coming.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Try those things and see if you get further.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;....edit....what Dan said....&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 09 Jun 2016 17:55:29 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/setparameterastext-to-view-python-tool-results/m-p/580708#M45546</guid>
      <dc:creator>RebeccaStrauch__GISP</dc:creator>
      <dc:date>2016-06-09T17:55:29Z</dc:date>
    </item>
    <item>
      <title>Re: SetParameterAsText To View Python Tool Results</title>
      <link>https://community.esri.com/t5/python-questions/setparameterastext-to-view-python-tool-results/m-p/580709#M45547</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Good points, I have used py 3 several times and had issues not being able to print until I learned about needing parenthesis. So good practice to use them in py 2 as well since it will work.&lt;/P&gt;&lt;P&gt;I would only use the r' raw for paths that were not for my pc, but I will include it every time now.&lt;/P&gt;&lt;P&gt;I made the other suggested changes and trying to grasp what Rebecca and Dan said to arrive at the edited code which states message has not been defined after running the script.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;#Import Modules
import csv,os,arcpy

#Set variables
ifile&amp;nbsp; = open('PythonShellSave.csv','r')
reader = csv.reader(ifile)
featureclass = input("Name of the feature class ? ")
#featureclass = arcpy.GetParameterAsText(0)

#Set path location of Excel (CSV) file 
path = r'C:\UsersWriteMxdInfoToExcel'
arcpy.env.workspace = path

#Create Function
def myMsgs(message):
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddMessage(msessage)
&amp;nbsp;&amp;nbsp;&amp;nbsp; print (message)

#CSV Module terminology row is horizontal &amp;amp; field is vertical;column is horizontal &amp;amp; row is vertical for excel
for row in reader:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for field in row:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if field == featureclass:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; final = row[4] + " " + featureclass
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print (final)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; myMsgs(message)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
#Close Excel (CSV) file
ifile.close()&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 00:58:31 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/setparameterastext-to-view-python-tool-results/m-p/580709#M45547</guid>
      <dc:creator>DevinUnderwood2</dc:creator>
      <dc:date>2021-12-12T00:58:31Z</dc:date>
    </item>
    <item>
      <title>Re: SetParameterAsText To View Python Tool Results</title>
      <link>https://community.esri.com/t5/python-questions/setparameterastext-to-view-python-tool-results/m-p/580710#M45548</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;your first variable should be&lt;/P&gt;&lt;P&gt;message = ""&amp;nbsp;&amp;nbsp;&amp;nbsp; # two double or two single quotes&lt;/P&gt;&lt;P&gt;also&lt;/P&gt;&lt;P&gt;print(message)&amp;nbsp;&amp;nbsp; # no spaces between print and the bracket&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 09 Jun 2016 20:44:20 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/setparameterastext-to-view-python-tool-results/m-p/580710#M45548</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2016-06-09T20:44:20Z</dc:date>
    </item>
    <item>
      <title>Re: SetParameterAsText To View Python Tool Results</title>
      <link>https://community.esri.com/t5/python-questions/setparameterastext-to-view-python-tool-results/m-p/580711#M45549</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;if you are going to us&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; myMsgs(message)&lt;/P&gt;&lt;P&gt;as you show in line 25, then you need to have a&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; myMsgs(final)&lt;/P&gt;&lt;P&gt;just link you are trying to print in line 24....which line 24 could be commented out.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;the myMsgs(message)&amp;nbsp; assuming that the variable "message" is already set, and passes the value of it to the function.&amp;nbsp; if you want that line to stay as is, then add&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; message = final&lt;/P&gt;&lt;P&gt;before that....assuming&amp;nbsp; "final" is a good variable.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 09 Jun 2016 20:50:49 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/setparameterastext-to-view-python-tool-results/m-p/580711#M45549</guid>
      <dc:creator>RebeccaStrauch__GISP</dc:creator>
      <dc:date>2016-06-09T20:50:49Z</dc:date>
    </item>
    <item>
      <title>Re: SetParameterAsText To View Python Tool Results</title>
      <link>https://community.esri.com/t5/python-questions/setparameterastext-to-view-python-tool-results/m-p/580712#M45550</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you for taking the time to further explain.&amp;nbsp; Will this work in a script that I am using with a tool I created? To automatically display message to results?&amp;nbsp; I tested out the function but it is not automatic when run and seen in python shell. However, as mentioned, my actual goal is to use it as a tool.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I will take a look at the Blog, thanks.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 09 Jun 2016 21:46:11 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/setparameterastext-to-view-python-tool-results/m-p/580712#M45550</guid>
      <dc:creator>DevinUnderwood2</dc:creator>
      <dc:date>2016-06-09T21:46:11Z</dc:date>
    </item>
    <item>
      <title>Re: SetParameterAsText To View Python Tool Results</title>
      <link>https://community.esri.com/t5/python-questions/setparameterastext-to-view-python-tool-results/m-p/580713#M45551</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I believe this reflects your comments.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;#Import Modules
import csv,os,arcpy

#Set variables
ifile&amp;nbsp; = open('PythonShellSave.csv','r')
reader = csv.reader(ifile)
featureclass = input("Name of the feature class ? ")
#featureclass = arcpy.GetParameterAsText(0)

#Set path location of Excel (CSV) file 
path = r'C:\Users\dunderwood\Documents\My Python Scripts\WriteMxdInfoToExcel'
arcpy.env.workspace = path

#Create Function
def myMsgs(message):
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddMessage(message)
&amp;nbsp;&amp;nbsp;&amp;nbsp; print(message)

#CSV Module terminology row is horizontal &amp;amp; field is vertical;column is horizontal &amp;amp; row is vertical for excel
for row in reader:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for field in row:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if field == featureclass:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; final = row[4] + " " + featureclass
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; #print(final)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; message = final
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; myMsgs(message)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
#Close Excel (CSV) file
ifile.close()&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 00:58:33 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/setparameterastext-to-view-python-tool-results/m-p/580713#M45551</guid>
      <dc:creator>DevinUnderwood2</dc:creator>
      <dc:date>2021-12-12T00:58:33Z</dc:date>
    </item>
    <item>
      <title>Re: SetParameterAsText To View Python Tool Results</title>
      <link>https://community.esri.com/t5/python-questions/setparameterastext-to-view-python-tool-results/m-p/580714#M45552</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Not running it myself, if it works in the python window, I would think it would run as a tool. One more warning, try to keep away from any spaces or special characters in file names/paths.&amp;nbsp; I may work, but it will come back to bite you at some points.&amp;nbsp; Also, keep filenames and field names short, i.e. not ThisIsAFieldNameForWhoKnowsWhat &lt;/P&gt;&lt;P&gt;&lt;A href="https://community.esri.com/migration-blogpost/55759"&gt;How To Name Things In ArcGIS&lt;/A&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; in&amp;nbsp;&amp;nbsp; &lt;A href="https://community.esri.com/migration-blogpost/1848"&gt;Curtis Price's Blog&lt;/A&gt;&amp;nbsp; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 09 Jun 2016 22:27:56 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/setparameterastext-to-view-python-tool-results/m-p/580714#M45552</guid>
      <dc:creator>RebeccaStrauch__GISP</dc:creator>
      <dc:date>2016-06-09T22:27:56Z</dc:date>
    </item>
    <item>
      <title>Re: SetParameterAsText To View Python Tool Results</title>
      <link>https://community.esri.com/t5/python-questions/setparameterastext-to-view-python-tool-results/m-p/580715#M45553</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Make sense, I will make note of creating better naming conventions.&lt;/P&gt;&lt;P&gt;Interesting how when I run it&amp;nbsp; as a tool the results yield successful but the add message doesn't appear.&lt;/P&gt;&lt;P&gt;Maybe my tool parameters are set incorrectly.&lt;/P&gt;&lt;P&gt;The tool works fine as I use&amp;nbsp; a dropdown to navigate to location of featureclass. This is straight forward.&lt;/P&gt;&lt;P&gt;The output I am not entirely sure about.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG class="image-1 jive-image" src="https://community.esri.com/legacyfs/online/207359_pastedImage_2.png" style="max-height: 900px; max-width: 1200px;" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 09 Jun 2016 22:59:20 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/setparameterastext-to-view-python-tool-results/m-p/580715#M45553</guid>
      <dc:creator>DevinUnderwood2</dc:creator>
      <dc:date>2016-06-09T22:59:20Z</dc:date>
    </item>
    <item>
      <title>Re: SetParameterAsText To View Python Tool Results</title>
      <link>https://community.esri.com/t5/python-questions/setparameterastext-to-view-python-tool-results/m-p/580716#M45554</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hmm. Not sure off hand why the AddMessage wouldn't show up in results.&amp;nbsp; here i part of the results from one of my tools that is under construction....all those with the date/time tacked on the end are myMsgs&lt;/P&gt;&lt;P&gt;&lt;IMG alt="" class="image-1 jive-image" src="https://community.esri.com/legacyfs/online/207325_pastedImage_0.png" style="max-width: 1200px; max-height: 900px;" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 09 Jun 2016 23:22:09 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/setparameterastext-to-view-python-tool-results/m-p/580716#M45554</guid>
      <dc:creator>RebeccaStrauch__GISP</dc:creator>
      <dc:date>2016-06-09T23:22:09Z</dc:date>
    </item>
  </channel>
</rss>

