<?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: How to get field values from every feature, and place them in a comma seperated string? in Geoprocessing Questions</title>
    <link>https://community.esri.com/t5/geoprocessing-questions/how-to-get-field-values-from-every-feature-and/m-p/118124#M4101</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I was using an unwieldy model that I should have written in arcpy to begin with.&amp;nbsp; I actually managed to do so in a relatively quick manner, it works 10-100 x faster than model builder!&amp;nbsp; Troubleshooting it seems no longer necessary.&amp;nbsp; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 06 Feb 2016 23:02:54 GMT</pubDate>
    <dc:creator>MichaelKowalczyk</dc:creator>
    <dc:date>2016-02-06T23:02:54Z</dc:date>
    <item>
      <title>How to get field values from every feature, and place them in a comma seperated string?</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/how-to-get-field-values-from-every-feature-and/m-p/118118#M4095</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello, I have a modelbuilder tool with an iterator that produces a selection in another feature class each iteration.&amp;nbsp; I would like to get the value of a field from the records in each selection, and put them in a coma separated string.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have attempted to use an embedded python tool to use a search cursor over these records, but it does not seem to work.&amp;nbsp; I get a runtime error: cannot open '&amp;lt;&amp;lt;field name&amp;gt;&amp;gt;'&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Do you have any suggestions as to how to accomplish this?&amp;nbsp; Would a searchcursor work in an iterator model? Thank you.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;--&lt;/P&gt;&lt;P&gt;My python tool containing the search cursor.&amp;nbsp; It works as expected in isolation, but not in the model builder tool.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import arcpy
from arcpy import env
env.workspace = arcpy.GetParameterAsText(0) 

##import time
#from datetime import datetime

##current_time=time.strftime("%H:%M:%S")+" "+ time.strftime("%d/%m/%Y")


local_pairlist = "" #list will be populated with pair ids from paths in prevailing direction

#selected features

pathfc&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; = arcpy.GetParameterAsText(1)&amp;nbsp; #demand paths in prevailing direction

path_pair_id= str(arcpy.GetParameterAsText(2)) #pair id field


with arcpy.da.SearchCursor(pathfc,(path_pair_id,)) as path_cursor:


&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;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; newpair=path_row[0] 

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if local_pairlist == "":
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; local_pairlist+=newpair
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; else:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; local_pairlist+=r","+newpair
&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;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; #--//colection loop--#&amp;nbsp;&amp;nbsp; 

##print "OD Builder Finished!\n\nOutput table="+str(out_name)+"\n\nLocation: " + str(out_path)


arcpy.AddMessage("Subpairs saved!")
arcpy.SetParameter(3, local_pairlist) &lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 06:55:47 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/how-to-get-field-values-from-every-feature-and/m-p/118118#M4095</guid>
      <dc:creator>MichaelKowalczyk</dc:creator>
      <dc:date>2021-12-11T06:55:47Z</dc:date>
    </item>
    <item>
      <title>Re: How to get field values from every feature, and place them in a comma seperated string?</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/how-to-get-field-values-from-every-feature-and/m-p/118119#M4096</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I normally do more complex stuff like this in python.&lt;/P&gt;&lt;P&gt;So, could you show us your code?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 06 Feb 2016 06:51:21 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/how-to-get-field-values-from-every-feature-and/m-p/118119#M4096</guid>
      <dc:creator>NeilAyres</dc:creator>
      <dc:date>2016-02-06T06:51:21Z</dc:date>
    </item>
    <item>
      <title>Re: How to get field values from every feature, and place them in a comma seperated string?</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/how-to-get-field-values-from-every-feature-and/m-p/118120#M4097</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yes a search cursor will work in a model with an iterator in it.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here's a picture of the model i tested with:&lt;/P&gt;&lt;P&gt;&lt;IMG class="image-1 jive-image" height="264" src="https://community.esri.com/legacyfs/online/178489_pastedImage_0.png" style="width: 363px; height: 264.053px;" width="363" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here's the code used:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import arcpy


#Variables
fc = arcpy.GetParameterAsText(0)
fld = arcpy.GetParameterAsText(1)


mystring = ""
with arcpy.da.SearchCursor(fc,fld) as cursor:
&amp;nbsp;&amp;nbsp;&amp;nbsp; for row in cursor:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; mystring += str(row[0]) +","


arcpy.AddMessage(mystring[:-1])&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 06:55:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/how-to-get-field-values-from-every-feature-and/m-p/118120#M4097</guid>
      <dc:creator>WesMiller</dc:creator>
      <dc:date>2021-12-11T06:55:50Z</dc:date>
    </item>
    <item>
      <title>Re: How to get field values from every feature, and place them in a comma seperated string?</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/how-to-get-field-values-from-every-feature-and/m-p/118121#M4098</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you, &lt;SPAN class="j-post-author"&gt;&lt;STRONG&gt;&lt;A _jive_internal="true" data-avatarid="-1" data-userid="16710" data-username="wwmiller68" href="https://community.esri.com/people/wwmiller68"&gt;Wes Miller&lt;/A&gt;&lt;/STRONG&gt;&lt;/SPAN&gt;, for confirming that it should work.&amp;nbsp; My tool looked very much like yours.&amp;nbsp; However, I was getting an error that it could not open the specified field.&amp;nbsp; Do you have any suggestions?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 06 Feb 2016 20:48:58 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/how-to-get-field-values-from-every-feature-and/m-p/118121#M4098</guid>
      <dc:creator>MichaelKowalczyk</dc:creator>
      <dc:date>2016-02-06T20:48:58Z</dc:date>
    </item>
    <item>
      <title>Re: How to get field values from every feature, and place them in a comma seperated string?</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/how-to-get-field-values-from-every-feature-and/m-p/118122#M4099</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Could you post the error you are getting. Have you confirmed the field name exists? Could you also post the model you are using&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 06 Feb 2016 22:12:28 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/how-to-get-field-values-from-every-feature-and/m-p/118122#M4099</guid>
      <dc:creator>WesMiller</dc:creator>
      <dc:date>2016-02-06T22:12:28Z</dc:date>
    </item>
    <item>
      <title>Re: How to get field values from every feature, and place them in a comma seperated string?</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/how-to-get-field-values-from-every-feature-and/m-p/118123#M4100</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I actually ended up rewriting the tool from scratch in Python, and actually got at least a 10 fold improvement in performance!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 06 Feb 2016 22:59:25 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/how-to-get-field-values-from-every-feature-and/m-p/118123#M4100</guid>
      <dc:creator>MichaelKowalczyk</dc:creator>
      <dc:date>2016-02-06T22:59:25Z</dc:date>
    </item>
    <item>
      <title>Re: How to get field values from every feature, and place them in a comma seperated string?</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/how-to-get-field-values-from-every-feature-and/m-p/118124#M4101</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I was using an unwieldy model that I should have written in arcpy to begin with.&amp;nbsp; I actually managed to do so in a relatively quick manner, it works 10-100 x faster than model builder!&amp;nbsp; Troubleshooting it seems no longer necessary.&amp;nbsp; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 06 Feb 2016 23:02:54 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/how-to-get-field-values-from-every-feature-and/m-p/118124#M4101</guid>
      <dc:creator>MichaelKowalczyk</dc:creator>
      <dc:date>2016-02-06T23:02:54Z</dc:date>
    </item>
    <item>
      <title>Re: How to get field values from every feature, and place them in a comma seperated string?</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/how-to-get-field-values-from-every-feature-and/m-p/118125#M4102</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yes,&lt;/P&gt;&lt;P&gt;there have been other post here about the speed improvements once a task is coded using arcpy / python.&lt;/P&gt;&lt;P&gt;Good to see you have your solution.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 08 Feb 2016 08:22:08 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/how-to-get-field-values-from-every-feature-and/m-p/118125#M4102</guid>
      <dc:creator>NeilAyres</dc:creator>
      <dc:date>2016-02-08T08:22:08Z</dc:date>
    </item>
  </channel>
</rss>

