Multivalue Parameter in Custom tool adds extra quotes

Discussion created by cndnflyr on Jul 19, 2012
Latest reply on Oct 11, 2012 by cndnflyr
I struggled with this tool for many hours before I realized what was going wrong and why.  The issue was with a space in the name of the Feature layers that were being chosen in a multivalue parameter.  So this string would be returned: "'blah blah\blah';'meh meh\meh'".  Then when I tried to split out the string with .split(";"), the extra quotes would stay with the string and the tool that this value was passed to would break.  When there wasn't a space in the chosen parameters, I would get something like this: "blah;meh" and that would work fine.

Do I need to make this check in all my code when I don't know what the users will choose?  I haven't seen this in any of the examples in the help, so it caught me by surprise.  How do other people deal with this?

Here is the code that I came up with that works.

import os
import arcpy as ap

lines = ap.GetParameterAsText(0).split(";")
claims = ap.GetParameterAsText(1).replace("'","")
claims = claims.split(";")

for line in lines:
    for claim in claims:
        output = os.path.join(ap.GetParameterAsText(2),line + "_" + claim.split("\\")[1])
        ap.Intersect_analysis([line, claim],output,"","","LINE")