<?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 Using multivalue parameters in a custom toolbox script in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/using-multivalue-parameters-in-a-custom-toolbox/m-p/504738#M39624</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have a custom toolbox which I added a python script too. The script currently runs when the input parameters are not multivalue, but the script falls over when I set the input parameters to multivalue. Where they seem to be falling over is when I try to use pyodbc to connect to an access database. I am currently using the arcpy.GetParameterAsText function and then using the split function to separate the semicolon delimited string into a list.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This is the error information that I am currently receiving.&lt;/P&gt;&lt;P&gt;Error Info:&lt;/P&gt;&lt;P&gt;&amp;lt;class 'pyodbc.Error'&amp;gt;: ('HY000', "[HY000] [Microsoft][ODBC Microsoft Access Driver] Not a valid file name. (-1044) (SQLDriverConnect); [01000] [Microsoft][ODBC Microsoft Access Driver]General Warning Unable to open registry key 'Temporary (volatile) Jet DSN for process 0x1200 Thread 0x128c DBC 0x24d28a4 Jet'. (1); [01000] [Microsoft][ODBC Microsoft Access Driver]General Warning Unable to open registry key 'Temporary (volatile) Jet DSN for process 0x1200 Thread 0x128c DBC 0x24d28a4 Jet'. (1); [HY000] [Microsoft][ODBC Microsoft Access Driver] Not a valid file name. (-1044)")&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;A snippet of my code:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import arcpy
import pyodbc
import sys
import os
import pythonaddins

SAGIS_Input = arcpy.GetParameterAsText(0)
SAGIS_model_new = SAGIS_Input.split(";")
SAGIS_Count = len(SAGIS_model_new)
arcpy.AddMessage(SAGIS_Count)
for model in SAGIS_model_new:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; SAGIS_model = str(model)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddMessage(SAGIS_model)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # connection to SAGIS model geodatabase
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; access_conn = pyodbc.connect('DRIVER={Microsoft Access Driver (*.mdb)};DBQ='+SAGIS_model)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; access_cursor = access_conn.cursor()


&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; tablelist = arcpy.ListTables()
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; tablecount = len(tablelist)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddMessage(tablecount)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddMessage("Script run successfully.")
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; #print "Script run successful."

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; access_cursor.close()
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; access_conn.close()&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I would very much appreciate any advise on how to get the muiltvalue paramters to work with the pyodbc connection.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks in advance.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Ben.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 11 Dec 2021 22:08:34 GMT</pubDate>
    <dc:creator>BenjaminSimpson</dc:creator>
    <dc:date>2021-12-11T22:08:34Z</dc:date>
    <item>
      <title>Using multivalue parameters in a custom toolbox script</title>
      <link>https://community.esri.com/t5/python-questions/using-multivalue-parameters-in-a-custom-toolbox/m-p/504738#M39624</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have a custom toolbox which I added a python script too. The script currently runs when the input parameters are not multivalue, but the script falls over when I set the input parameters to multivalue. Where they seem to be falling over is when I try to use pyodbc to connect to an access database. I am currently using the arcpy.GetParameterAsText function and then using the split function to separate the semicolon delimited string into a list.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This is the error information that I am currently receiving.&lt;/P&gt;&lt;P&gt;Error Info:&lt;/P&gt;&lt;P&gt;&amp;lt;class 'pyodbc.Error'&amp;gt;: ('HY000', "[HY000] [Microsoft][ODBC Microsoft Access Driver] Not a valid file name. (-1044) (SQLDriverConnect); [01000] [Microsoft][ODBC Microsoft Access Driver]General Warning Unable to open registry key 'Temporary (volatile) Jet DSN for process 0x1200 Thread 0x128c DBC 0x24d28a4 Jet'. (1); [01000] [Microsoft][ODBC Microsoft Access Driver]General Warning Unable to open registry key 'Temporary (volatile) Jet DSN for process 0x1200 Thread 0x128c DBC 0x24d28a4 Jet'. (1); [HY000] [Microsoft][ODBC Microsoft Access Driver] Not a valid file name. (-1044)")&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;A snippet of my code:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import arcpy
import pyodbc
import sys
import os
import pythonaddins

SAGIS_Input = arcpy.GetParameterAsText(0)
SAGIS_model_new = SAGIS_Input.split(";")
SAGIS_Count = len(SAGIS_model_new)
arcpy.AddMessage(SAGIS_Count)
for model in SAGIS_model_new:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; SAGIS_model = str(model)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddMessage(SAGIS_model)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # connection to SAGIS model geodatabase
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; access_conn = pyodbc.connect('DRIVER={Microsoft Access Driver (*.mdb)};DBQ='+SAGIS_model)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; access_cursor = access_conn.cursor()


&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; tablelist = arcpy.ListTables()
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; tablecount = len(tablelist)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddMessage(tablecount)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddMessage("Script run successfully.")
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; #print "Script run successful."

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; access_cursor.close()
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; access_conn.close()&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I would very much appreciate any advise on how to get the muiltvalue paramters to work with the pyodbc connection.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks in advance.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Ben.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 22:08:34 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/using-multivalue-parameters-in-a-custom-toolbox/m-p/504738#M39624</guid>
      <dc:creator>BenjaminSimpson</dc:creator>
      <dc:date>2021-12-11T22:08:34Z</dc:date>
    </item>
    <item>
      <title>Re: Using multivalue parameters in a custom toolbox script</title>
      <link>https://community.esri.com/t5/python-questions/using-multivalue-parameters-in-a-custom-toolbox/m-p/504739#M39625</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Have you tried adding a message to the dialog to verify the name returned for your model? The values should come in as a string delimited by semi-colons. I would assume that most likely the quotes may be coming in if you have spaces in the strings and you need to strip them out.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 14 Dec 2015 18:26:48 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/using-multivalue-parameters-in-a-custom-toolbox/m-p/504739#M39625</guid>
      <dc:creator>FreddieGibson</dc:creator>
      <dc:date>2015-12-14T18:26:48Z</dc:date>
    </item>
    <item>
      <title>Re: Using multivalue parameters in a custom toolbox script</title>
      <link>https://community.esri.com/t5/python-questions/using-multivalue-parameters-in-a-custom-toolbox/m-p/504740#M39626</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;ArcGIS wraps parameters with spaces in them in single quotes when passing multivalue parameters.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If I run the following script as a toolbox script tool and pass it "a b c" and&amp;nbsp; "abc" as the first parameter, I get the below output&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;SPAN style="color: #000080; font-weight: bold;"&gt;import &lt;/SPAN&gt;arcpy

SAGIS_Input = arcpy.GetParameterAsText(&lt;SPAN style="color: #0000ff;"&gt;0&lt;/SPAN&gt;)
SAGIS_model_new = SAGIS_Input.split(&lt;SPAN style="color: #008000; font-weight: bold;"&gt;";"&lt;/SPAN&gt;)
SAGIS_Count = &lt;SPAN style="color: #000080;"&gt;len&lt;/SPAN&gt;(SAGIS_model_new)
&lt;SPAN style="color: #000080; font-weight: bold;"&gt;for &lt;/SPAN&gt;model &lt;SPAN style="color: #000080; font-weight: bold;"&gt;in &lt;/SPAN&gt;SAGIS_model_new:
&amp;nbsp; arcpy.AddMessage(model)&lt;/PRE&gt;&lt;P&gt;&lt;IMG alt="results.png" class="image-1 jive-image" src="https://community.esri.com/legacyfs/online/156153_results.png" style="height: auto;" /&gt;&lt;/P&gt;&lt;P&gt;Notice the single quotes around the values 'a b c'?&lt;/P&gt;&lt;P&gt;You need to strip them off with something like:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;SPAN style="color: #000080; font-weight: bold;"&gt;for &lt;/SPAN&gt;model &lt;SPAN style="color: #000080; font-weight: bold;"&gt;in &lt;/SPAN&gt;SAGIS_model_new:
&amp;nbsp; model = model.strip("'")&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 22:08:37 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/using-multivalue-parameters-in-a-custom-toolbox/m-p/504740#M39626</guid>
      <dc:creator>Luke_Pinner</dc:creator>
      <dc:date>2021-12-11T22:08:37Z</dc:date>
    </item>
    <item>
      <title>Re: Using multivalue parameters in a custom toolbox script</title>
      <link>https://community.esri.com/t5/python-questions/using-multivalue-parameters-in-a-custom-toolbox/m-p/504741#M39627</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you both for your helpful advice. Stripping the single quotes worked a treat. Your help is much appreciated.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 15 Dec 2015 08:48:31 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/using-multivalue-parameters-in-a-custom-toolbox/m-p/504741#M39627</guid>
      <dc:creator>BenjaminSimpson</dc:creator>
      <dc:date>2015-12-15T08:48:31Z</dc:date>
    </item>
  </channel>
</rss>

