<?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: Script tool multiple input fields parameter...HELP! in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/script-tool-multiple-input-fields-parameter-help/m-p/179749#M13808</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Maybe it's just a copy/paste error, but your message call is not within the loop. It should be more like:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;SPAN style="background-color: inherit; color: black; font-weight: inherit; font-size: 9pt !important; font-style: inherit;"&gt;with arcpy.da.SearchCursor(inFeat, [fields]) as cursor: &lt;/SPAN&gt;
&lt;SPAN style="font-weight: inherit; font-style: inherit; color: black; font-size: 9pt !important; background-color: inherit;"&gt;&lt;SPAN class="keyword" style="font-weight: inherit; font-style: inherit; color: #006699; font-size: 9pt !important; background-color: inherit;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; for&lt;/SPAN&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-size: 9pt !important; background-color: inherit;"&gt; row &lt;/SPAN&gt;&lt;SPAN class="keyword" style="font-weight: inherit; font-style: inherit; color: #006699; font-size: 9pt !important; background-color: inherit;"&gt;in&lt;/SPAN&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-size: 9pt !important; background-color: inherit;"&gt; cursor: &lt;/SPAN&gt;&lt;/SPAN&gt;
&lt;SPAN style="font-weight: inherit; font-style: inherit; color: black; font-size: 9pt !important; background-color: inherit;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddMessage(&lt;SPAN class="string" style="font-weight: inherit; font-style: inherit; color: blue; font-size: 9pt !important; background-color: inherit;"&gt;"{0} | Phase: {1} | OH/UG: {2}"&lt;/SPAN&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-size: 9pt !important; background-color: inherit;"&gt;.format(row[&lt;/SPAN&gt;&lt;SPAN class="number" style="font-weight: inherit; font-style: inherit; color: green; font-size: 9pt !important; background-color: inherit;"&gt;0&lt;/SPAN&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-size: 9pt !important; background-color: inherit;"&gt;], row[&lt;/SPAN&gt;&lt;SPAN class="number" style="font-weight: inherit; font-style: inherit; color: green; font-size: 9pt !important; background-color: inherit;"&gt;1&lt;/SPAN&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-size: 9pt !important; background-color: inherit;"&gt;], row[&lt;/SPAN&gt;&lt;SPAN class="number" style="font-weight: inherit; font-style: inherit; color: green; font-size: 9pt !important; background-color: inherit;"&gt;2&lt;/SPAN&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-size: 9pt !important; background-color: inherit;"&gt;]))&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I suspect your larger problem is that fields is just &lt;STRONG&gt;text&lt;/STRONG&gt;, not a &lt;STRONG&gt;list&lt;/STRONG&gt;. You will likely have to parse the semicolon-delimited string into an iterable list before referencing it in the cursor.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 11 Dec 2021 09:12:02 GMT</pubDate>
    <dc:creator>DarrenWiens2</dc:creator>
    <dc:date>2021-12-11T09:12:02Z</dc:date>
    <item>
      <title>Script tool multiple input fields parameter...HELP!</title>
      <link>https://community.esri.com/t5/python-questions/script-tool-multiple-input-fields-parameter-help/m-p/179746#M13805</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have a script tool where it takes an input table and "MULTIPLE INPUT FIELDS"&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It then runs a cursor and all i want to do is print out each row with the 3 field values.&amp;nbsp; If i do 3 parameters for the fields, it works.&amp;nbsp; If i do the mutliple it wont.&amp;nbsp; I tried printing out the value and it looked like this:&amp;nbsp; fields = "ID;Lat:Long"&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I guess it needs to be in list format to run through the cursor as a row?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here is my code&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;inFeat = arcpy.GetParameterAsText(&lt;SPAN style="color: #6897bb;"&gt;0&lt;/SPAN&gt;)
fields = arcpy.GetParameterAsText(&lt;SPAN style="color: #6897bb;"&gt;1&lt;/SPAN&gt;)

&lt;SPAN style="color: #cc7832; font-weight: bold;"&gt;with &lt;/SPAN&gt;arcpy.da.SearchCursor(inFeat&lt;SPAN style="color: #cc7832;"&gt;, &lt;/SPAN&gt;[fields]) &lt;SPAN style="color: #cc7832; font-weight: bold;"&gt;as &lt;/SPAN&gt;cursor:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="color: #cc7832; font-weight: bold;"&gt;for &lt;/SPAN&gt;row &lt;SPAN style="color: #cc7832; font-weight: bold;"&gt;in &lt;/SPAN&gt;cursor:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddMessage(row[&lt;SPAN style="color: #6897bb;"&gt;0&lt;/SPAN&gt;]&lt;SPAN style="color: #cc7832;"&gt;, &lt;/SPAN&gt;row[&lt;SPAN style="color: #6897bb;"&gt;1&lt;/SPAN&gt;]&lt;SPAN style="color: #cc7832;"&gt;, &lt;/SPAN&gt;row[&lt;SPAN style="color: #6897bb;"&gt;2&lt;/SPAN&gt;])&lt;/PRE&gt;&lt;P&gt;&lt;BR /&gt; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 09:11:56 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/script-tool-multiple-input-fields-parameter-help/m-p/179746#M13805</guid>
      <dc:creator>MatthewRusso</dc:creator>
      <dc:date>2021-12-11T09:11:56Z</dc:date>
    </item>
    <item>
      <title>Re: Script tool multiple input fields parameter...HELP!</title>
      <link>https://community.esri.com/t5/python-questions/script-tool-multiple-input-fields-parameter-help/m-p/179747#M13806</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;So, this code works, or not? It shouldn't, as your message is not indented within the for loop...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Can you also clarify what "it doesn't work" means? Is there an error? If so, what is it?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Finally, can you check your output: &lt;SPAN style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;fields = "ID;Lat:Long" Are you sure these aren't all semicolons(;)?&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 03 Mar 2015 21:06:51 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/script-tool-multiple-input-fields-parameter-help/m-p/179747#M13806</guid>
      <dc:creator>DarrenWiens2</dc:creator>
      <dc:date>2015-03-03T21:06:51Z</dc:date>
    </item>
    <item>
      <title>Re: Script tool multiple input fields parameter...HELP!</title>
      <link>https://community.esri.com/t5/python-questions/script-tool-multiple-input-fields-parameter-help/m-p/179748#M13807</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;On my Testing script it looks like this&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;fields = arcpy.GetParameterAsText(&lt;SPAN style="color: #6897bb;"&gt;1&lt;/SPAN&gt;)&amp;nbsp; &lt;SPAN style="color: #158000;"&gt;# Multiple Input Script Tool&lt;/SPAN&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if i do arcpy.AddMessage(fields) the output is: FID;Latitude;Longitude # The Three selected fields&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if I try to take my "fields" parameter and insert it into my cursor, it pops an error on the for loop line: &lt;STRONG&gt;RuntimeError: A column was specified that does not exist.&lt;/STRONG&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;&lt;SPAN style="color: #cc7832; font-weight: bold;"&gt;with &lt;/SPAN&gt;arcpy.da.SearchCursor(inFeat&lt;SPAN style="color: #cc7832;"&gt;, &lt;/SPAN&gt;[fields]) &lt;SPAN style="color: #cc7832; font-weight: bold;"&gt;as &lt;/SPAN&gt;cursor:
&lt;SPAN style="color: #cc7832; font-weight: bold;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for &lt;/SPAN&gt;row &lt;SPAN style="color: #cc7832; font-weight: bold;"&gt;in &lt;/SPAN&gt;cursor:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddMessage(&lt;SPAN style="color: #a5c261;"&gt;"{0} | Phase: {1} | OH/UG: {2}"&lt;/SPAN&gt;.format(row[&lt;SPAN style="color: #6897bb;"&gt;0&lt;/SPAN&gt;]&lt;SPAN style="color: #cc7832;"&gt;, &lt;/SPAN&gt;row[&lt;SPAN style="color: #6897bb;"&gt;1&lt;/SPAN&gt;]&lt;SPAN style="color: #cc7832;"&gt;, &lt;/SPAN&gt;row[&lt;SPAN style="color: #6897bb;"&gt;2&lt;/SPAN&gt;]))&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This is what im working with&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hopefully that is better information for you&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 09:11:59 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/script-tool-multiple-input-fields-parameter-help/m-p/179748#M13807</guid>
      <dc:creator>MatthewRusso</dc:creator>
      <dc:date>2021-12-11T09:11:59Z</dc:date>
    </item>
    <item>
      <title>Re: Script tool multiple input fields parameter...HELP!</title>
      <link>https://community.esri.com/t5/python-questions/script-tool-multiple-input-fields-parameter-help/m-p/179749#M13808</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Maybe it's just a copy/paste error, but your message call is not within the loop. It should be more like:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;SPAN style="background-color: inherit; color: black; font-weight: inherit; font-size: 9pt !important; font-style: inherit;"&gt;with arcpy.da.SearchCursor(inFeat, [fields]) as cursor: &lt;/SPAN&gt;
&lt;SPAN style="font-weight: inherit; font-style: inherit; color: black; font-size: 9pt !important; background-color: inherit;"&gt;&lt;SPAN class="keyword" style="font-weight: inherit; font-style: inherit; color: #006699; font-size: 9pt !important; background-color: inherit;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; for&lt;/SPAN&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-size: 9pt !important; background-color: inherit;"&gt; row &lt;/SPAN&gt;&lt;SPAN class="keyword" style="font-weight: inherit; font-style: inherit; color: #006699; font-size: 9pt !important; background-color: inherit;"&gt;in&lt;/SPAN&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-size: 9pt !important; background-color: inherit;"&gt; cursor: &lt;/SPAN&gt;&lt;/SPAN&gt;
&lt;SPAN style="font-weight: inherit; font-style: inherit; color: black; font-size: 9pt !important; background-color: inherit;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddMessage(&lt;SPAN class="string" style="font-weight: inherit; font-style: inherit; color: blue; font-size: 9pt !important; background-color: inherit;"&gt;"{0} | Phase: {1} | OH/UG: {2}"&lt;/SPAN&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-size: 9pt !important; background-color: inherit;"&gt;.format(row[&lt;/SPAN&gt;&lt;SPAN class="number" style="font-weight: inherit; font-style: inherit; color: green; font-size: 9pt !important; background-color: inherit;"&gt;0&lt;/SPAN&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-size: 9pt !important; background-color: inherit;"&gt;], row[&lt;/SPAN&gt;&lt;SPAN class="number" style="font-weight: inherit; font-style: inherit; color: green; font-size: 9pt !important; background-color: inherit;"&gt;1&lt;/SPAN&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-size: 9pt !important; background-color: inherit;"&gt;], row[&lt;/SPAN&gt;&lt;SPAN class="number" style="font-weight: inherit; font-style: inherit; color: green; font-size: 9pt !important; background-color: inherit;"&gt;2&lt;/SPAN&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-size: 9pt !important; background-color: inherit;"&gt;]))&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I suspect your larger problem is that fields is just &lt;STRONG&gt;text&lt;/STRONG&gt;, not a &lt;STRONG&gt;list&lt;/STRONG&gt;. You will likely have to parse the semicolon-delimited string into an iterable list before referencing it in the cursor.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 09:12:02 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/script-tool-multiple-input-fields-parameter-help/m-p/179749#M13808</guid>
      <dc:creator>DarrenWiens2</dc:creator>
      <dc:date>2021-12-11T09:12:02Z</dc:date>
    </item>
    <item>
      <title>Re: Script tool multiple input fields parameter...HELP!</title>
      <link>https://community.esri.com/t5/python-questions/script-tool-multiple-input-fields-parameter-help/m-p/179750#M13809</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The list of fields depends on the way you read your parameter.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you use "arcpy.GetParameterAsTekst()", then the list will be &lt;SPAN style="line-height: 1.5;"&gt;a single string where the different items are separated by semicolons. To avoid this you could use "arcpy.GetParameter()", this will yield a list of field objects. Neither one of them is directly useful for specifying the fields in a cursor.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;# use:
fldstekst = arcpy.GetParameterAsText(1)
flds = fldstekst.split(';')
# or:
lst_flds = arcpy.GetParameter(2)
flds = [fld.name for fld in lst_flds]

# then use:
with arcpy.da.SearchCursor(inFeat, flds) 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; arcpy.AddMessage(row[0], row[1], row[2])&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Be aware that if less than 3 fields have been selected that this will yield an error (index out of range).&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 09:12:05 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/script-tool-multiple-input-fields-parameter-help/m-p/179750#M13809</guid>
      <dc:creator>XanderBakker</dc:creator>
      <dc:date>2021-12-11T09:12:05Z</dc:date>
    </item>
    <item>
      <title>Re: Script tool multiple input fields parameter...HELP!</title>
      <link>https://community.esri.com/t5/python-questions/script-tool-multiple-input-fields-parameter-help/m-p/179751#M13810</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The split did the trick, i tried that earlier but i believe that i put a ',' not a ';' in.&lt;/P&gt;&lt;P&gt;Thanks for the help&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 04 Mar 2015 13:21:35 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/script-tool-multiple-input-fields-parameter-help/m-p/179751#M13810</guid>
      <dc:creator>MatthewRusso</dc:creator>
      <dc:date>2015-03-04T13:21:35Z</dc:date>
    </item>
  </channel>
</rss>

