<?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 Data List paths in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/script-tool-data-list-paths/m-p/479971#M37543</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Is there a better way to use the multivalue property in a script tool? &lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;You could use GetParameter() instead of GetParameterAsText() and process it as a value table. This is the only approach for example, with a list of layer names if you want to handle layers that contain ";".&amp;nbsp; It's a lot more complicated to work with parameter objects, and harder to debug, so I try to avoid doing it that way.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Are you sure you are getting quotes? The best way to check is with repr:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;CensusDataList = arcpy.GetParameterAsText(0).split(";") for d in CensusDataList: &amp;nbsp;&amp;nbsp;&amp;nbsp; print repr(d)&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If you do indeed have extra quotes, you could strip them like this:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;CensusDataList = string.split(arcpy.GetParameterAsText(0), ";") CensusDataList = [d.strip("'") for d in CensusDataList] &lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;And avoid spaces in paths -- just trouble as far as I'm concerned!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;One more thing, in arcpy, tools can read lists, so you don't need to join them back together with ";" delimiters:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;#Loop through each state directory in the list to create an input value (another list) hzCounties = ["{}\\bndrygbs.mdb\\hzCounty".format(p)&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; for p in CensusDataList]&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 19 Jun 2013 23:03:31 GMT</pubDate>
    <dc:creator>curtvprice</dc:creator>
    <dc:date>2013-06-19T23:03:31Z</dc:date>
    <item>
      <title>Script tool Data List paths</title>
      <link>https://community.esri.com/t5/python-questions/script-tool-data-list-paths/m-p/479970#M37542</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Is there a better way to use the multivalue property in a script tool?&amp;nbsp; This code works except when the paths to folders have spaces.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;# Script arguments CensusDataList = string.split(arcpy.GetParameterAsText(0), ";")&amp;nbsp; #Loop through each state directory in the list to create an input value. for CensusState in CensusDataList: &amp;nbsp;&amp;nbsp;&amp;nbsp; CensusFeaturePath = CensusState + "\\bndrygbs.mdb\\hzCounty" &amp;nbsp;&amp;nbsp;&amp;nbsp; hzCounty_Inputs = hzCounty_Inputs + ";" + CensusFeaturePath &lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If the paths for&amp;nbsp; CensusDataList are something like: &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Path 1&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Path 2&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I get&amp;nbsp; 'Path 1';'Path 2' for the list.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If the paths are something like: &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Path1&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Path2&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I get Path1;Path2 for the list.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 19 Jun 2013 18:32:47 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/script-tool-data-list-paths/m-p/479970#M37542</guid>
      <dc:creator>JimHall</dc:creator>
      <dc:date>2013-06-19T18:32:47Z</dc:date>
    </item>
    <item>
      <title>Re: Script tool Data List paths</title>
      <link>https://community.esri.com/t5/python-questions/script-tool-data-list-paths/m-p/479971#M37543</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Is there a better way to use the multivalue property in a script tool? &lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;You could use GetParameter() instead of GetParameterAsText() and process it as a value table. This is the only approach for example, with a list of layer names if you want to handle layers that contain ";".&amp;nbsp; It's a lot more complicated to work with parameter objects, and harder to debug, so I try to avoid doing it that way.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Are you sure you are getting quotes? The best way to check is with repr:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;CensusDataList = arcpy.GetParameterAsText(0).split(";") for d in CensusDataList: &amp;nbsp;&amp;nbsp;&amp;nbsp; print repr(d)&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If you do indeed have extra quotes, you could strip them like this:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;CensusDataList = string.split(arcpy.GetParameterAsText(0), ";") CensusDataList = [d.strip("'") for d in CensusDataList] &lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;And avoid spaces in paths -- just trouble as far as I'm concerned!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;One more thing, in arcpy, tools can read lists, so you don't need to join them back together with ";" delimiters:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;#Loop through each state directory in the list to create an input value (another list) hzCounties = ["{}\\bndrygbs.mdb\\hzCounty".format(p)&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; for p in CensusDataList]&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 19 Jun 2013 23:03:31 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/script-tool-data-list-paths/m-p/479971#M37543</guid>
      <dc:creator>curtvprice</dc:creator>
      <dc:date>2013-06-19T23:03:31Z</dc:date>
    </item>
    <item>
      <title>Re: Script tool Data List paths</title>
      <link>https://community.esri.com/t5/python-questions/script-tool-data-list-paths/m-p/479972#M37544</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;It is the script tool form that is adding in the extra quote only when needed.&amp;nbsp; This or the spaces break the tool inputs further in my code.&amp;nbsp; I did the following which allows paths to folders to have spaces or not and generate the list of data for processing. I left in my old code commented out for comparison.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
#the script tool is looking for multiple folders here
CensusDataList = string.split(arcpy.GetParameterAsText(0), ";")

CensusDataList = [d.strip("'") for d in CensusDataList]

#Loop through each state directory in the list to create input values.

#for CensusState in CensusDataList:
&amp;nbsp;&amp;nbsp;&amp;nbsp; #CensusFeaturePath = CensusState + "\\bndrygbs.mdb\\hzCounty"
&amp;nbsp;&amp;nbsp;&amp;nbsp; #hzCounty_Inputs = hzCounty_Inputs + ";" + CensusFeaturePath
hzCounty_Inputs = ["{0}\\bndrygbs.mdb\\hzCounty".format(p)
&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; for p in CensusDataList]

&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I agree that spaces should not be used in paths but.....&amp;nbsp; :rolleyes:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks for your help!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 21:11:15 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/script-tool-data-list-paths/m-p/479972#M37544</guid>
      <dc:creator>JimHall</dc:creator>
      <dc:date>2021-12-11T21:11:15Z</dc:date>
    </item>
  </channel>
</rss>

