<?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: Projected datasets in one single line using a script tool in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/projected-datasets-in-one-single-line-using-a/m-p/41914#M3356</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Ahmed,&lt;/P&gt;&lt;P&gt;Thanks for the guidance here. I am looking to achieve the same goal with the script results separated by a comma. When I use the syntax;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;myList = reprojectedFCs&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;x = ", ".join(myList)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;arcpy.AddMessage("Projected " + str(x))&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;I end up with commas before and after every single letter - instead of after each feature class. I am new to scripting, any idea what I am doing wrong here? &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;Thanks,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;Evan&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 03 Nov 2014 23:27:13 GMT</pubDate>
    <dc:creator>EvanEchlin</dc:creator>
    <dc:date>2014-11-03T23:27:13Z</dc:date>
    <item>
      <title>Projected datasets in one single line using a script tool</title>
      <link>https://community.esri.com/t5/python-questions/projected-datasets-in-one-single-line-using-a/m-p/41910#M3352</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I'm writing a script in python to re-project a set of shapefiles, and I want to report these re-projected shapefiles in a geoprocessing message in "a single line" seperated by commas with no trailing comma at the end, after processing the script tool. I used arcpy.AddMessage(), however, it reported the results in separate lines. I would like to mention that I used a loop here to list all features inside workspace i.e. ListFeatureClasses()&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Does anyone have any idea of doing that?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 15 Oct 2011 03:01:40 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/projected-datasets-in-one-single-line-using-a/m-p/41910#M3352</guid>
      <dc:creator>AhmedAldossary</dc:creator>
      <dc:date>2011-10-15T03:01:40Z</dc:date>
    </item>
    <item>
      <title>Re: Projected datasets in one single line using a script tool</title>
      <link>https://community.esri.com/t5/python-questions/projected-datasets-in-one-single-line-using-a/m-p/41911#M3353</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I was able to do this by appending the feature classes to a list, writing the list to a text file, reading the text file as a string while removing the last comma, and then finally writing the string using the arcpy.AddMessage function.&amp;nbsp; Here is an example of how to do this with a list of feature classes:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import arcpy, os
from arcpy import env
env.workspace = r"C:\temp\python\test.gdb"

# Create an empty list
list = []

# Create a text file
output = open(r"C:\temp\python\list.txt", "w")

lstFCs = arcpy.ListFeatureClasses("*")
for fc in lstFCs:
&amp;nbsp;&amp;nbsp;&amp;nbsp; list.append(fc)

# write each feature class to the text file
for n in list:
&amp;nbsp;&amp;nbsp;&amp;nbsp; output.write(n + " ")

# read the text file and add commas
output = open(r"C:\temp\python\list.txt", "r")

s = output.read()
s = s.rstrip()
s = s.replace(" ", ", ")

arcpy.AddMessage(s)

# close and delete the text file
output.close()
os.remove(r"C:\temp\python\list.txt")&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Dec 2021 21:37:07 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/projected-datasets-in-one-single-line-using-a/m-p/41911#M3353</guid>
      <dc:creator>JakeSkinner</dc:creator>
      <dc:date>2021-12-10T21:37:07Z</dc:date>
    </item>
    <item>
      <title>Re: Projected datasets in one single line using a script tool</title>
      <link>https://community.esri.com/t5/python-questions/projected-datasets-in-one-single-line-using-a/m-p/41912#M3354</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thank you Jake for your help. You gave me an idea of to use a list to display the feature classes, although I took a different approach instead of writing feature classes to a text file. To explain more, after the loop, I convert the list to string using: &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;x = ", ".join(myList)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Then I used that in the geoprocessing tool as follows:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.AddMessage("Projected " + str(x))&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Again, thank you for your help!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 17 Oct 2011 13:04:28 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/projected-datasets-in-one-single-line-using-a/m-p/41912#M3354</guid>
      <dc:creator>AhmedAldossary</dc:creator>
      <dc:date>2011-10-17T13:04:28Z</dc:date>
    </item>
    <item>
      <title>Re: Projected datasets in one single line using a script tool</title>
      <link>https://community.esri.com/t5/python-questions/projected-datasets-in-one-single-line-using-a/m-p/41913#M3355</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Awesome, your method will be much easier!&amp;nbsp; I was having trouble figuring out how to convert a list to a string.&amp;nbsp; Thanks for the syntax:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;x = ", ".join(myList)&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 17 Oct 2011 13:11:47 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/projected-datasets-in-one-single-line-using-a/m-p/41913#M3355</guid>
      <dc:creator>JakeSkinner</dc:creator>
      <dc:date>2011-10-17T13:11:47Z</dc:date>
    </item>
    <item>
      <title>Re: Projected datasets in one single line using a script tool</title>
      <link>https://community.esri.com/t5/python-questions/projected-datasets-in-one-single-line-using-a/m-p/41914#M3356</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Ahmed,&lt;/P&gt;&lt;P&gt;Thanks for the guidance here. I am looking to achieve the same goal with the script results separated by a comma. When I use the syntax;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;myList = reprojectedFCs&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;x = ", ".join(myList)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;arcpy.AddMessage("Projected " + str(x))&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;I end up with commas before and after every single letter - instead of after each feature class. I am new to scripting, any idea what I am doing wrong here? &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;Thanks,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;Evan&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 03 Nov 2014 23:27:13 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/projected-datasets-in-one-single-line-using-a/m-p/41914#M3356</guid>
      <dc:creator>EvanEchlin</dc:creator>
      <dc:date>2014-11-03T23:27:13Z</dc:date>
    </item>
    <item>
      <title>Re: Projected datasets in one single line using a script tool</title>
      <link>https://community.esri.com/t5/python-questions/projected-datasets-in-one-single-line-using-a/m-p/41915#M3357</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;if myList contains only 1 object ie len(myList) == 1 then join, split etc indeed any list function will interate through the individual components.&lt;/P&gt;&lt;P&gt;So just check first if len(myList) &amp;gt; 1, before using ",".join(myList)&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 05 Nov 2014 08:11:20 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/projected-datasets-in-one-single-line-using-a/m-p/41915#M3357</guid>
      <dc:creator>NeilAyres</dc:creator>
      <dc:date>2014-11-05T08:11:20Z</dc:date>
    </item>
  </channel>
</rss>

