<?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 Re: Calculate Fields Using Python in Geoprocessing Questions</title>
    <link>https://community.esri.com/t5/geoprocessing-questions/calculate-fields-using-python/m-p/559549#M18529</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Robert,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You could incorporate an IF statement to determine if the field is blank.&amp;nbsp; If it is, then you can run the calculation.&amp;nbsp; Ex:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG alt="screen1.PNG" class="image-1 jive-image" src="https://community.esri.com/legacyfs/online/126159_screen1.PNG" style="height: auto;" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 09 Sep 2015 15:23:28 GMT</pubDate>
    <dc:creator>JakeSkinner</dc:creator>
    <dc:date>2015-09-09T15:23:28Z</dc:date>
    <item>
      <title>Calculate Fields Using Python</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/calculate-fields-using-python/m-p/559548#M18528</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have some tables in our Enterprise GeoDatabase that are used in a Map Service for another application, Cityworks 2013. To link the table asset to other data created in Cityworks (Work orders, etc.), a particular field must be designated for linking. This field must be unique and unchanging for each asset row in the table, and also the application is being used to add new assets to said tables. When a new asset record is added by Cityworks it does not automatically calculate the field designated for linking in the correct method. It simply places an OBJECT ID in that field, but we need it to also have a combination of other attributes. When performing a mass upload of this tabular asset data into our GeoDatabase I employed &lt;STRONG&gt;Field Calculator&lt;/STRONG&gt; to update these fields using a concatenation Python Expression: &lt;STRONG&gt;"%s-%s-%s" % ('CP', !Field1!, !Field2!)&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I would like to automated this expression to update this field on a regular basis, but cannot figure out a way to only update new records that have been added by the application and not overwrite existing data. Any help would be greatly appreciated!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Robert&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 09 Sep 2015 14:43:24 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/calculate-fields-using-python/m-p/559548#M18528</guid>
      <dc:creator>RobertBradley1</dc:creator>
      <dc:date>2015-09-09T14:43:24Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate Fields Using Python</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/calculate-fields-using-python/m-p/559549#M18529</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Robert,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You could incorporate an IF statement to determine if the field is blank.&amp;nbsp; If it is, then you can run the calculation.&amp;nbsp; Ex:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG alt="screen1.PNG" class="image-1 jive-image" src="https://community.esri.com/legacyfs/online/126159_screen1.PNG" style="height: auto;" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 09 Sep 2015 15:23:28 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/calculate-fields-using-python/m-p/559549#M18529</guid>
      <dc:creator>JakeSkinner</dc:creator>
      <dc:date>2015-09-09T15:23:28Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate Fields Using Python</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/calculate-fields-using-python/m-p/559550#M18530</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks Jake but in my statement 'CP' is not a field but just a text string I'm adding. Also I am only trying to update one field, called &lt;STRONG&gt;CityworksID &lt;/STRONG&gt;not three. Basically I need it to look at that field, determine if it meets certain qualifications (i.e. maybe if it contains 'CP'), and if not update to a concatenated value using the string text 'CP' + !Field1! (an asset type)+ !Field2! (a number)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For example the final value would be &lt;STRONG&gt;CP-PUMP1-0001&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for helping!!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 09 Sep 2015 15:51:54 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/calculate-fields-using-python/m-p/559550#M18530</guid>
      <dc:creator>RobertBradley1</dc:creator>
      <dc:date>2015-09-09T15:51:54Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate Fields Using Python</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/calculate-fields-using-python/m-p/559551#M18531</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I would use select by attribute to isolate the new records then run your field calculator.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 09 Sep 2015 16:04:38 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/calculate-fields-using-python/m-p/559551#M18531</guid>
      <dc:creator>WesMiller</dc:creator>
      <dc:date>2015-09-09T16:04:38Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate Fields Using Python</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/calculate-fields-using-python/m-p/559552#M18532</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Your expression would be:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;CityworksID=
myFunction(!CityworksID!, !Field1!, !Field2!)&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;and the code block:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;def myFunction(cw, f1, f2):
&amp;nbsp;&amp;nbsp;&amp;nbsp; if 'CP' not in cw:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return cw # or some other default
&amp;nbsp;&amp;nbsp;&amp;nbsp; else:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return 'CP-' + f1 + str(f2)&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 00:08:38 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/calculate-fields-using-python/m-p/559552#M18532</guid>
      <dc:creator>DarrenWiens2</dc:creator>
      <dc:date>2021-12-12T00:08:38Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate Fields Using Python</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/calculate-fields-using-python/m-p/559553#M18533</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you Darren!! I think this might just work. Didn't think about using myFunction &lt;/P&gt;&lt;P&gt;Going to test this on a test database right away.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 09 Sep 2015 18:55:05 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/calculate-fields-using-python/m-p/559553#M18533</guid>
      <dc:creator>RobertBradley1</dc:creator>
      <dc:date>2015-09-09T18:55:05Z</dc:date>
    </item>
  </channel>
</rss>

