<?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 field calculator python expression with parameters in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/field-calculator-python-expression-with-parameters/m-p/748587#M57847</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi, I am trying to concatonate an existing field with a parameter in a python script&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;parameter = 4&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;expression = !field! + ", " + parameter&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.management.CalculateField("testshp", "field", expression, "PYTHON")&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;my field is a text field with a value of "1, 2, 3" and i want to make it "1, 2, 3, 4" where everytime the script runs and the user inputs &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;a number it adds a comma, a space, then the parameter. I keep running into issues with combining a string and an int but the parameter is preset to string. Any ideas? Thanks.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 11 Mar 2013 00:07:21 GMT</pubDate>
    <dc:creator>jamesborris</dc:creator>
    <dc:date>2013-03-11T00:07:21Z</dc:date>
    <item>
      <title>field calculator python expression with parameters</title>
      <link>https://community.esri.com/t5/python-questions/field-calculator-python-expression-with-parameters/m-p/748587#M57847</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi, I am trying to concatonate an existing field with a parameter in a python script&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;parameter = 4&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;expression = !field! + ", " + parameter&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.management.CalculateField("testshp", "field", expression, "PYTHON")&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;my field is a text field with a value of "1, 2, 3" and i want to make it "1, 2, 3, 4" where everytime the script runs and the user inputs &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;a number it adds a comma, a space, then the parameter. I keep running into issues with combining a string and an int but the parameter is preset to string. Any ideas? Thanks.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 11 Mar 2013 00:07:21 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/field-calculator-python-expression-with-parameters/m-p/748587#M57847</guid>
      <dc:creator>jamesborris</dc:creator>
      <dc:date>2013-03-11T00:07:21Z</dc:date>
    </item>
    <item>
      <title>Re: field calculator python expression with parameters</title>
      <link>https://community.esri.com/t5/python-questions/field-calculator-python-expression-with-parameters/m-p/748588#M57848</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Maybe you should try,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;expression = !field! + ", " + str(parameter)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Hi, I am trying to concatonate an existing field with a parameter in a python script&lt;BR /&gt;&lt;BR /&gt;parameter = 4&lt;BR /&gt;expression = !field! + ", " + parameter&lt;BR /&gt;arcpy.management.CalculateField("testshp", "field", expression, "PYTHON")&lt;BR /&gt;&lt;BR /&gt;my field is a text field with a value of "1, 2, 3" and i want to make it "1, 2, 3, 4" where everytime the script runs and the user inputs &lt;BR /&gt;a number it adds a comma, a space, then the parameter. I keep running into issues with combining a string and an int but the parameter is preset to string. Any ideas? Thanks.&lt;/BLOCKQUOTE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 11 Mar 2013 02:14:19 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/field-calculator-python-expression-with-parameters/m-p/748588#M57848</guid>
      <dc:creator>ChrisPedrezuela</dc:creator>
      <dc:date>2013-03-11T02:14:19Z</dc:date>
    </item>
    <item>
      <title>Re: field calculator python expression with parameters</title>
      <link>https://community.esri.com/t5/python-questions/field-calculator-python-expression-with-parameters/m-p/748589#M57849</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Maybe you should try,&lt;BR /&gt;&lt;BR /&gt;expression = !field! + ", " + str(parameter)&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I agree. James, what is the data type of your field? If you set parameter = 4, that is making it an integer. To make that a string you would need to say parameter = "4". Because you cannot concatenate strings with integers, you will need to make sure the two match. If field is a string, set parameter = "4". If the field is an integer, you will want to set parameter = 4. Otherwise, you can cast it to string or int in the expression by saying int(parameter) or str(parameter), just as suggested above.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 11 Mar 2013 15:51:01 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/field-calculator-python-expression-with-parameters/m-p/748589#M57849</guid>
      <dc:creator>LucasDanzinger</dc:creator>
      <dc:date>2013-03-11T15:51:01Z</dc:date>
    </item>
  </channel>
</rss>

