<?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: Learning Python ArcMap in Data Management Questions</title>
    <link>https://community.esri.com/t5/data-management-questions/learning-python-arcmap/m-p/360270#M20624</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Can I do the same thing for deleting rows based off of a certain field?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;gt;&amp;gt;&amp;gt; with arcpy.da.UpdateCursor("Export_Output",["ZONE_SUBTY"])as rows: &lt;BR /&gt;... for row in rows: &lt;BR /&gt;... if row in ["AREA OF MINIMAL FLOOD HAZARD"]&lt;BR /&gt;... row.deleteRow(row)&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 21 Nov 2018 19:34:00 GMT</pubDate>
    <dc:creator>RyanPhillips2</dc:creator>
    <dc:date>2018-11-21T19:34:00Z</dc:date>
    <item>
      <title>Learning Python ArcMap</title>
      <link>https://community.esri.com/t5/data-management-questions/learning-python-arcmap/m-p/360267#M20621</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello! I am still in the learning stages of Python coding for ArcMap and have run into a bit of a snag. I am trying to calculate some fields based off of other fields in the attribute table. I am using the arcpy. CalculateField_management command and i'm not sure if I can throw an "IF",... "Then" statement&amp;nbsp; in there to calculate that field based off of another fields records. This is what I have, which is not working&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;arcpy.CalculateField_management("SD_FP_Pro","SYM",&lt;BR /&gt;... if["FLD_ZONE] = "A","AE","AH","AO","VE" then "SYM" = "100"&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I feel like I am combining two things that do not go together.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 21 Nov 2018 17:35:56 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/learning-python-arcmap/m-p/360267#M20621</guid>
      <dc:creator>RyanPhillips2</dc:creator>
      <dc:date>2018-11-21T17:35:56Z</dc:date>
    </item>
    <item>
      <title>Re: Learning Python ArcMap</title>
      <link>https://community.esri.com/t5/data-management-questions/learning-python-arcmap/m-p/360268#M20622</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I generally only use Calculate Field in&amp;nbsp;&lt;A href="https://community.esri.com/space/2145" target="_blank"&gt;Python&lt;/A&gt; scripts if the expression is simple, like copying a field or assigning a field to a single value or expression.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you have embedded if-then logic, I suggest using UpdateCursor:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;with arcpy.da.UpdateCursor("SD_FP_PRO", ["SYM", "FLD_ZONE"]) as rows:
&amp;nbsp;&amp;nbsp;&amp;nbsp; for row in rows:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if row[1] in ["A", "AE", "AH", "AO", "VE"]:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; row[0] = 100
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; rows.updateRow(row)‍‍‍‍‍‍‍‍‍‍&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A class="link-titled" href="http://desktop.arcgis.com/en/arcmap/latest/analyze/arcpy-data-access/updatecursor-class.htm" title="http://desktop.arcgis.com/en/arcmap/latest/analyze/arcpy-data-access/updatecursor-class.htm" rel="nofollow noopener noreferrer" target="_blank"&gt;UpdateCursor—Help | ArcGIS Desktop&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now, if you are not in a python script and instead using the Calculate Field tool interactively or in Model Builder, a code block is your best bet:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;&lt;SPAN class="comment token"&gt;# Calculate Field tool&lt;/SPAN&gt;
&lt;SPAN class="comment token"&gt;# input table&lt;/SPAN&gt;
SD_FP_PRO
&lt;SPAN class="comment token"&gt;# input field&lt;/SPAN&gt;
SYM
&lt;SPAN class="comment token"&gt;# expression&lt;/SPAN&gt;
f&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;!FLD_ZONE!&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
&lt;SPAN class="comment token"&gt;# code block&lt;/SPAN&gt;
&lt;SPAN class="keyword token"&gt;def&lt;/SPAN&gt; &lt;SPAN class="token function"&gt;f&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;fz&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="keyword token"&gt;if&lt;/SPAN&gt; fz &lt;SPAN class="keyword token"&gt;in&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"A"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"AE"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"AH"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"AO"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"VE"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="keyword token"&gt;return&lt;/SPAN&gt; &lt;SPAN class="number token"&gt;100&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="keyword token"&gt;else&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="keyword token"&gt;return&lt;/SPAN&gt; fz‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this helps you out.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 16:48:26 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/learning-python-arcmap/m-p/360268#M20622</guid>
      <dc:creator>curtvprice</dc:creator>
      <dc:date>2021-12-11T16:48:26Z</dc:date>
    </item>
    <item>
      <title>Re: Learning Python ArcMap</title>
      <link>https://community.esri.com/t5/data-management-questions/learning-python-arcmap/m-p/360269#M20623</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you so much Mr. Price&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 21 Nov 2018 18:56:01 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/learning-python-arcmap/m-p/360269#M20623</guid>
      <dc:creator>RyanPhillips2</dc:creator>
      <dc:date>2018-11-21T18:56:01Z</dc:date>
    </item>
    <item>
      <title>Re: Learning Python ArcMap</title>
      <link>https://community.esri.com/t5/data-management-questions/learning-python-arcmap/m-p/360270#M20624</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Can I do the same thing for deleting rows based off of a certain field?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;gt;&amp;gt;&amp;gt; with arcpy.da.UpdateCursor("Export_Output",["ZONE_SUBTY"])as rows: &lt;BR /&gt;... for row in rows: &lt;BR /&gt;... if row in ["AREA OF MINIMAL FLOOD HAZARD"]&lt;BR /&gt;... row.deleteRow(row)&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 21 Nov 2018 19:34:00 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/learning-python-arcmap/m-p/360270#M20624</guid>
      <dc:creator>RyanPhillips2</dc:creator>
      <dc:date>2018-11-21T19:34:00Z</dc:date>
    </item>
    <item>
      <title>Re: Learning Python ArcMap</title>
      <link>https://community.esri.com/t5/data-management-questions/learning-python-arcmap/m-p/360271#M20625</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Perhaps, but the usual method of doing this task is to create a layer with Create Feature Layer, run a selection on it with Select Layer By Attributes, and then&amp;nbsp;use the DeleteFeatures tool. (Or probably better, copy selected rows you want to a new dataset so you don't destroy data rows you may want later!)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Glad this helped!&lt;/P&gt;&lt;P&gt;May I share a little forum etiquette: a) please use a subject line that describes the content ("Python if then within field calculation")&amp;nbsp;b) when you get a useful answer, mark it correct.&amp;nbsp;These actions make&amp;nbsp;the formum thread more useful for others in the community.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 22 Nov 2018 17:08:02 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/learning-python-arcmap/m-p/360271#M20625</guid>
      <dc:creator>curtvprice</dc:creator>
      <dc:date>2018-11-22T17:08:02Z</dc:date>
    </item>
  </channel>
</rss>

