<?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 Passing parameters to the featureLayer.calculate in ArcGIS API for Python Questions</title>
    <link>https://community.esri.com/t5/arcgis-api-for-python-questions/passing-parameters-to-the-featurelayer-calculate/m-p/1088582#M6484</link>
    <description>&lt;P&gt;I'm sure this is a simple issue, but it's stumped me.&lt;/P&gt;&lt;P&gt;The following line executes without issue:&lt;/P&gt;&lt;P&gt;fs_layer.calculate(where="FIPS=18039", calc_expression={"field":"VERSION", "value": "07/04/2021"})&lt;/P&gt;&lt;P&gt;This fails:&lt;/P&gt;&lt;P&gt;where_str = '"FIPS=18039"'&lt;BR /&gt;calc_str = '"field":"VERSION", "value":"07/10/2021"'&lt;BR /&gt;fs_layer.calculate(where=where_str, calc_expression={calc_str})&lt;/P&gt;&lt;P&gt;Ultimately I want to iterate the fs_layer.calculate line in a loop, passing different FIPS and VERSION values each time.&lt;/P&gt;&lt;P&gt;I've tried multiple ways to build the parameters to be passed, building the entire argument, varying quote schemes, and so on. What am I missing?&lt;/P&gt;</description>
    <pubDate>Thu, 12 Aug 2021 18:41:28 GMT</pubDate>
    <dc:creator>ChuckBenton</dc:creator>
    <dc:date>2021-08-12T18:41:28Z</dc:date>
    <item>
      <title>Passing parameters to the featureLayer.calculate</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/passing-parameters-to-the-featurelayer-calculate/m-p/1088582#M6484</link>
      <description>&lt;P&gt;I'm sure this is a simple issue, but it's stumped me.&lt;/P&gt;&lt;P&gt;The following line executes without issue:&lt;/P&gt;&lt;P&gt;fs_layer.calculate(where="FIPS=18039", calc_expression={"field":"VERSION", "value": "07/04/2021"})&lt;/P&gt;&lt;P&gt;This fails:&lt;/P&gt;&lt;P&gt;where_str = '"FIPS=18039"'&lt;BR /&gt;calc_str = '"field":"VERSION", "value":"07/10/2021"'&lt;BR /&gt;fs_layer.calculate(where=where_str, calc_expression={calc_str})&lt;/P&gt;&lt;P&gt;Ultimately I want to iterate the fs_layer.calculate line in a loop, passing different FIPS and VERSION values each time.&lt;/P&gt;&lt;P&gt;I've tried multiple ways to build the parameters to be passed, building the entire argument, varying quote schemes, and so on. What am I missing?&lt;/P&gt;</description>
      <pubDate>Thu, 12 Aug 2021 18:41:28 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/passing-parameters-to-the-featurelayer-calculate/m-p/1088582#M6484</guid>
      <dc:creator>ChuckBenton</dc:creator>
      <dc:date>2021-08-12T18:41:28Z</dc:date>
    </item>
    <item>
      <title>Re: Passing parameters to the featureLayer.calculate</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/passing-parameters-to-the-featurelayer-calculate/m-p/1088593#M6485</link>
      <description>&lt;P&gt;just as you might have a string going to a string within a list, the quotes aren't removed. e.g.&lt;/P&gt;&lt;LI-CODE lang="python"&gt;my_string = 'a'
my_list = [my_string]

# so my_list looks like ['a'], not [a]

my_string = "I've made a string"
my_list = [my_string]

#... &lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;containing the string in curly braces acts in the same way as the list forcing, calc_expression just becomes a set containing the string.&lt;/P&gt;</description>
      <pubDate>Thu, 12 Aug 2021 19:06:44 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/passing-parameters-to-the-featurelayer-calculate/m-p/1088593#M6485</guid>
      <dc:creator>DavidPike</dc:creator>
      <dc:date>2021-08-12T19:06:44Z</dc:date>
    </item>
    <item>
      <title>Re: Passing parameters to the featureLayer.calculate</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/passing-parameters-to-the-featurelayer-calculate/m-p/1088604#M6486</link>
      <description>&lt;P&gt;This doesn't seem to be the issue. I've converted to lists and run the following:&lt;/P&gt;&lt;P&gt;where_str = '"FIPS=18039"'&lt;BR /&gt;where_list = [where_str]&lt;BR /&gt;calc_str = '"field":"VERSION", "value":"07/10/2021"'&lt;BR /&gt;calc_list = [calc_str]&lt;BR /&gt;print("where="+where_list[0]+", calc_expression={"+calc_list[0]+"}")&lt;BR /&gt;fs_layer.calculate(where=where_list[0], calc_expression={calc_list[0]})&lt;/P&gt;&lt;P&gt;I added the print line to confirm formatting, its output:&lt;/P&gt;&lt;PRE&gt;where="FIPS=18039", calc_expression={"field":"VERSION", "value":"07/10/2021"}&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;I get the same error as when I passed the strings:&lt;/P&gt;&lt;PRE&gt;&lt;SPAN class="ansi-red-intense-fg ansi-bold"&gt;Exception&lt;/SPAN&gt;: 
Invalid parameters
(Error Code: 400)&lt;/PRE&gt;&lt;P&gt;Keep in mind this line works:&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;fs_layer.calculate(where="FIPS=18039", calc_expression={"field":"VERSION", "value": "07/04/2021"})&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;I'm still stumped....&lt;/P&gt;</description>
      <pubDate>Thu, 12 Aug 2021 19:24:48 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/passing-parameters-to-the-featurelayer-calculate/m-p/1088604#M6486</guid>
      <dc:creator>ChuckBenton</dc:creator>
      <dc:date>2021-08-12T19:24:48Z</dc:date>
    </item>
    <item>
      <title>Re: Passing parameters to the featureLayer.calculate</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/passing-parameters-to-the-featurelayer-calculate/m-p/1088632#M6487</link>
      <description>&lt;P&gt;Forget about the list, it's just an example of what's going on.&amp;nbsp; When printing calc_expression, it looks like a dictionary but it's not - it's still a string.&amp;nbsp; Check this by using the type() method - e.g. print(type(calc_expression))&lt;/P&gt;&lt;P&gt;you'll see the one which works is a dict, the other is either a set or a string.&lt;/P&gt;&lt;P&gt;What's the purpose of trying to use the first method to create the dictionary?&lt;/P&gt;</description>
      <pubDate>Thu, 12 Aug 2021 20:30:26 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/passing-parameters-to-the-featurelayer-calculate/m-p/1088632#M6487</guid>
      <dc:creator>DavidPike</dc:creator>
      <dc:date>2021-08-12T20:30:26Z</dc:date>
    </item>
    <item>
      <title>Re: Passing parameters to the featureLayer.calculate</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/passing-parameters-to-the-featurelayer-calculate/m-p/1088680#M6490</link>
      <description>&lt;P&gt;What I need is a generic function I can call, passing it a FIPS and date (both as strings). I have about 150M records, spread among about 2000 distinct FIPS values, for which I want to update the VERSION fields. Something like&lt;/P&gt;&lt;P&gt;def updateRecords(fips, version_date)&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;fs_layer.calculate(where=fips, , calc_expression={"field":"ATTDATE", "value": version_date})&lt;/P&gt;&lt;P&gt;Of course, passing the parameters to work within .calculate is the issue. As you've probably guessed, I'm not a Python expert!&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance for your advice!&lt;/P&gt;</description>
      <pubDate>Thu, 12 Aug 2021 22:06:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/passing-parameters-to-the-featurelayer-calculate/m-p/1088680#M6490</guid>
      <dc:creator>ChuckBenton</dc:creator>
      <dc:date>2021-08-12T22:06:50Z</dc:date>
    </item>
    <item>
      <title>Re: Passing parameters to the featureLayer.calculate</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/passing-parameters-to-the-featurelayer-calculate/m-p/1088691#M6491</link>
      <description>&lt;P&gt;ok so you just need to construct a dictionary with the function.&lt;/P&gt;&lt;LI-CODE lang="python"&gt;def updateRecords(fips, version_date):
    calc_dict = {}
    calc_dict['field'] = 'ATTDATE'
    calc_dict['value'] = version_date
    fs_layer.calculate(where=fips, , calc_expression=calc_dict)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 12 Aug 2021 22:26:01 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/passing-parameters-to-the-featurelayer-calculate/m-p/1088691#M6491</guid>
      <dc:creator>DavidPike</dc:creator>
      <dc:date>2021-08-12T22:26:01Z</dc:date>
    </item>
    <item>
      <title>Re: Passing parameters to the featureLayer.calculate</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/passing-parameters-to-the-featurelayer-calculate/m-p/1088703#M6493</link>
      <description>&lt;P&gt;Thanks so much! Still struggling with one last detail.&lt;/P&gt;&lt;P&gt;def updateRecords(fips, version_date):&lt;BR /&gt;&amp;nbsp; &amp;nbsp; fips = '"FIPS=' +fips+'"'&lt;BR /&gt;&amp;nbsp; &amp;nbsp;print(fips)&lt;BR /&gt;&amp;nbsp; &amp;nbsp;calc_dict = {}&lt;BR /&gt;&amp;nbsp; &amp;nbsp;calc_dict['field'] = 'VERSION'&lt;BR /&gt;&amp;nbsp; &amp;nbsp;calc_dict['value'] = '"' + version_date + '"'&lt;BR /&gt;&amp;nbsp; &amp;nbsp;fs_layer.calculate(where=fips, calc_expression=calc_dict)&lt;/P&gt;&lt;P&gt;The print statement yields&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;"FIPS=06007"&lt;/PRE&gt;&lt;P&gt;but I get&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;SPAN class="ansi-red-intense-fg ansi-bold"&gt;Exception&lt;/SPAN&gt;: 
'where' parameter is invalid
(Error Code: 400)&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;Change the last line to&amp;nbsp;&lt;/P&gt;&lt;P&gt;fs_layer.calculate(where="FIPS=06007", calc_expression=calc_dict)&lt;/P&gt;&lt;P&gt;and all works.&lt;/P&gt;&lt;P&gt;I'm still missing something that's not jumping out to me.&lt;/P&gt;&lt;P&gt;Thanks again for helping a newbie!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 12 Aug 2021 23:45:52 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/passing-parameters-to-the-featurelayer-calculate/m-p/1088703#M6493</guid>
      <dc:creator>ChuckBenton</dc:creator>
      <dc:date>2021-08-12T23:45:52Z</dc:date>
    </item>
    <item>
      <title>Re: Passing parameters to the featureLayer.calculate</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/passing-parameters-to-the-featurelayer-calculate/m-p/1088711#M6494</link>
      <description>&lt;P&gt;not sure if FIPS is a string or Int, I'll assume its a string from your code&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;fips = '"FIPS" = "{0}"'.format(fips)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 13 Aug 2021 00:08:39 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/passing-parameters-to-the-featurelayer-calculate/m-p/1088711#M6494</guid>
      <dc:creator>DavidPike</dc:creator>
      <dc:date>2021-08-13T00:08:39Z</dc:date>
    </item>
    <item>
      <title>Re: Passing parameters to the featureLayer.calculate</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/passing-parameters-to-the-featurelayer-calculate/m-p/1089257#M6505</link>
      <description>&lt;P&gt;Still didn't do the trick.&lt;/P&gt;&lt;P&gt;fips = '"FIPS={0}"'.format(fips) yields&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;"FIPS" = "06007"&lt;/PRE&gt;&lt;P&gt;from the print, and&lt;/P&gt;&lt;PRE&gt;&lt;SPAN class="ansi-red-intense-fg ansi-bold"&gt;Exception&lt;/SPAN&gt;: 
'Invalid field: 06007' parameter is invalid
(Error Code: 400)&lt;/PRE&gt;&lt;P&gt;for the error.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Suggestions?&lt;/P&gt;</description>
      <pubDate>Mon, 16 Aug 2021 13:03:28 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/passing-parameters-to-the-featurelayer-calculate/m-p/1089257#M6505</guid>
      <dc:creator>ChuckBenton</dc:creator>
      <dc:date>2021-08-16T13:03:28Z</dc:date>
    </item>
    <item>
      <title>Re: Passing parameters to the featureLayer.calculate</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/passing-parameters-to-the-featurelayer-calculate/m-p/1089269#M6506</link>
      <description>&lt;P&gt;I don't know your data types. I've gone over what you previously have said has worked, and although I don't entirely understand the leading 0 and it not being a string, this will probably work:&lt;/P&gt;&lt;LI-CODE lang="c"&gt;"FIPS={0}".format(fips)
&lt;/LI-CODE&gt;</description>
      <pubDate>Mon, 16 Aug 2021 13:41:53 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/passing-parameters-to-the-featurelayer-calculate/m-p/1089269#M6506</guid>
      <dc:creator>DavidPike</dc:creator>
      <dc:date>2021-08-16T13:41:53Z</dc:date>
    </item>
    <item>
      <title>Re: Passing parameters to the featureLayer.calculate</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/passing-parameters-to-the-featurelayer-calculate/m-p/1089275#M6507</link>
      <description>&lt;P&gt;That did it. Thanks!!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 16 Aug 2021 13:59:23 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/passing-parameters-to-the-featurelayer-calculate/m-p/1089275#M6507</guid>
      <dc:creator>ChuckBenton</dc:creator>
      <dc:date>2021-08-16T13:59:23Z</dc:date>
    </item>
  </channel>
</rss>

