<?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 Spaces in String Variable in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/spaces-in-string-variable/m-p/74028#M6061</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I have an issue with my script related to the space in the string variable (see below). If "MinNPP" is used instead it works fine.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I've also tried setting the variable as str(arcpy.GetParameterAsText(6)) but it doesn't work either. The variable is set as String data type in the tool; Filter = Value list. Version used is 10.0&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Variable:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;NPPEquation = arcpy.GetParameterAsText(6)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Process:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;if NPPEquation == "Min NPP1":&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thank you&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Toni&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 20 Dec 2013 13:15:16 GMT</pubDate>
    <dc:creator>anTonialcaraz</dc:creator>
    <dc:date>2013-12-20T13:15:16Z</dc:date>
    <item>
      <title>Spaces in String Variable</title>
      <link>https://community.esri.com/t5/python-questions/spaces-in-string-variable/m-p/74028#M6061</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I have an issue with my script related to the space in the string variable (see below). If "MinNPP" is used instead it works fine.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I've also tried setting the variable as str(arcpy.GetParameterAsText(6)) but it doesn't work either. The variable is set as String data type in the tool; Filter = Value list. Version used is 10.0&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Variable:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;NPPEquation = arcpy.GetParameterAsText(6)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Process:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;if NPPEquation == "Min NPP1":&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thank you&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Toni&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 20 Dec 2013 13:15:16 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/spaces-in-string-variable/m-p/74028#M6061</guid>
      <dc:creator>anTonialcaraz</dc:creator>
      <dc:date>2013-12-20T13:15:16Z</dc:date>
    </item>
    <item>
      <title>Re: Spaces in String Variable</title>
      <link>https://community.esri.com/t5/python-questions/spaces-in-string-variable/m-p/74029#M6062</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Have you tried using print NPPEquation just to see exactly what is being returned by the GetParametersAsText.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;It should work, but only if NPPEquation is exactly "Min NPP1"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Not much, I know but good luck,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Neil&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 20 Dec 2013 13:32:13 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/spaces-in-string-variable/m-p/74029#M6062</guid>
      <dc:creator>NeilAyres</dc:creator>
      <dc:date>2013-12-20T13:32:13Z</dc:date>
    </item>
    <item>
      <title>Re: Spaces in String Variable</title>
      <link>https://community.esri.com/t5/python-questions/spaces-in-string-variable/m-p/74030#M6063</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi Toni,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;So do you have added "Min NPP1" to your filter value list? Are you sure there's no trailing space or whatsoever?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 20 Dec 2013 13:32:17 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/spaces-in-string-variable/m-p/74030#M6063</guid>
      <dc:creator>GeraldineEGGERMONT</dc:creator>
      <dc:date>2013-12-20T13:32:17Z</dc:date>
    </item>
    <item>
      <title>Re: Spaces in String Variable</title>
      <link>https://community.esri.com/t5/python-questions/spaces-in-string-variable/m-p/74031#M6064</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thanks a lot guys.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I tried the print NPPEquation and it works fine. "Min NPP1" is one of the values in the filter list.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The thing is that I've set the output raster dataset to include the name of the NPPEquation ("Min NPP" for example).&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;So I guess is not the right approach to have spaces in the string variable names. Not sure if there is a way round that...&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Cheers&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Toni&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 20 Dec 2013 14:03:07 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/spaces-in-string-variable/m-p/74031#M6064</guid>
      <dc:creator>anTonialcaraz</dc:creator>
      <dc:date>2013-12-20T14:03:07Z</dc:date>
    </item>
    <item>
      <title>Re: Spaces in String Variable</title>
      <link>https://community.esri.com/t5/python-questions/spaces-in-string-variable/m-p/74032#M6065</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;rasters don't like spaces in their names if this is indeed an output name&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 20 Dec 2013 16:52:39 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/spaces-in-string-variable/m-p/74032#M6065</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2013-12-20T16:52:39Z</dc:date>
    </item>
    <item>
      <title>Re: Spaces in String Variable</title>
      <link>https://community.esri.com/t5/python-questions/spaces-in-string-variable/m-p/74033#M6066</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Thanks a lot guys.&lt;BR /&gt;&lt;BR /&gt;I tried the print NPPEquation and it works fine. "Min NPP1" is one of the values in the filter list.&lt;BR /&gt;&lt;BR /&gt;The thing is that I've set the output raster dataset to include the name of the NPPEquation ("Min NPP" for example).&lt;BR /&gt;So I guess is not the right approach to have spaces in the string variable names. Not sure if there is a way round that...&lt;BR /&gt;&lt;BR /&gt;Cheers&lt;BR /&gt;&lt;BR /&gt;Toni&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Toni,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;You can use an IF statement to replace the space using python's replace method.&amp;nbsp; Example:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;if " " in NPPEquation:
&amp;nbsp;&amp;nbsp;&amp;nbsp; NPPEquation = NPPEquation.replace(" ", "_")&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Dec 2021 22:52:30 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/spaces-in-string-variable/m-p/74033#M6066</guid>
      <dc:creator>JakeSkinner</dc:creator>
      <dc:date>2021-12-10T22:52:30Z</dc:date>
    </item>
    <item>
      <title>Re: Spaces in String Variable</title>
      <link>https://community.esri.com/t5/python-questions/spaces-in-string-variable/m-p/74034#M6067</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thanks very much Jake.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;That helps a lot.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Toni&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 23 Dec 2013 07:09:13 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/spaces-in-string-variable/m-p/74034#M6067</guid>
      <dc:creator>anTonialcaraz</dc:creator>
      <dc:date>2013-12-23T07:09:13Z</dc:date>
    </item>
  </channel>
</rss>

