<?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: Updating the rows in one table based on values in another table or using nested cursors in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/updating-the-rows-in-one-table-based-on-values-in/m-p/614150#M47935</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;row is use in many part of your code.&amp;nbsp; Which specific line is throwing the error?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Also, do not use nested cursors.&amp;nbsp; They are horribly inefficient and in my opinion should never be used.&amp;nbsp; Instead first use a cursor to load the entire source you want to match into a dictionary and then run an updatecursor on the data that needs to match it using the dictionary to compare the values.&amp;nbsp; See my blog on the subject &lt;A _jive_internal="true" href="https://community.esri.com/blogs/richard_fairhurst/2014/11/08/turbo-charging-data-manipulation-with-python-cursors-and-dictionaries"&gt;here&lt;/A&gt; for some ideas of how this can be set up.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 21 Apr 2015 14:26:37 GMT</pubDate>
    <dc:creator>RichardFairhurst</dc:creator>
    <dc:date>2015-04-21T14:26:37Z</dc:date>
    <item>
      <title>Updating the rows in one table based on values in another table or using nested cursors</title>
      <link>https://community.esri.com/t5/python-questions/updating-the-rows-in-one-table-based-on-values-in/m-p/614147#M47932</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P style="color: #222222; font-family: arial, sans-serif; font-size: 12.8000001907349px;"&gt;I am finding it hard to articulate what I am trying to do, so here's what I have and here's where I'm going.&lt;/P&gt;&lt;P style="color: #222222; font-family: arial, sans-serif; font-size: 12.8000001907349px;"&gt;&lt;/P&gt;&lt;P style="color: #222222; font-family: arial, sans-serif; font-size: 12.8000001907349px;"&gt;I have: 4 raster datasets.&amp;nbsp; One is a set of drainage zones, one is the soil type, one is slope, and one is depth below surface. I also have a large table of stormwater practices and their associated physical constraints.&lt;/P&gt;&lt;P style="color: #222222; font-family: arial, sans-serif; font-size: 12.8000001907349px;"&gt;&lt;/P&gt;&lt;P style="color: #222222; font-family: arial, sans-serif; font-size: 12.8000001907349px;"&gt;Desired outcome: For each drainage zone, I want a list of stormwater practices that can go on the site.&lt;/P&gt;&lt;P style="color: #222222; font-family: arial, sans-serif; font-size: 12.8000001907349px;"&gt;&lt;/P&gt;&lt;P style="color: #222222; font-family: arial, sans-serif; font-size: 12.8000001907349px;"&gt;What I've done:&amp;nbsp; For each drainage zone, I have found the median slope and median depth below surface using Zonal Statistics.&amp;nbsp; I have combined the median slope, median depth, drainage zone, and soil type into a single raster dataset using the Combine function.&amp;nbsp; I have used the Build Raster Attribute Table to have all of those values available to me in a single table without converting it back to a shapefile.&amp;nbsp; I have a Cursor set up to duplicate the constraint table for each unique combination of drainage zone and soil type.&lt;/P&gt;&lt;P style="color: #222222; font-family: arial, sans-serif; font-size: 12.8000001907349px;"&gt;&lt;/P&gt;&lt;P style="color: #222222; font-family: arial, sans-serif; font-size: 12.8000001907349px;"&gt;What I want to do:&amp;nbsp; I want to compare the Combination table to the table of constraints and delete rows from the constraint table when certain conditions are met.&amp;nbsp; For example, some stormwater practices only work on soil types A and B, so if the soil type in the constraint table is not found in the row for the combination table, I want the row in the constraint table to be deleted.&amp;nbsp; Here is the code I have come up with to help you understand my goal.&lt;/P&gt;&lt;P style="color: #222222; font-family: arial, sans-serif; font-size: 12.8000001907349px;"&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
&lt;SPAN style="color: #808080; font-style: italic;"&gt;# Combine rasters to give unique combinations
&lt;/SPAN&gt;combo = arcpy.sa.Combine([DAras, EffHSG, med_WT, med_slope])
combo.save(WorkPath + &lt;SPAN style="color: #008000; font-weight: bold;"&gt;r"\combo"&lt;/SPAN&gt;)
combo_table = arcpy.BuildRasterAttributeTable_management(combo)

&lt;SPAN style="color: #808080; font-style: italic;"&gt;# Convert integer HSG code to string type
&lt;/SPAN&gt;arcpy.AddField_management(combo_table, &lt;SPAN style="color: #008000; font-weight: bold;"&gt;"HSG"&lt;/SPAN&gt;, &lt;SPAN style="color: #008000; font-weight: bold;"&gt;"TEXT"&lt;/SPAN&gt;, &lt;SPAN style="color: #008000; font-weight: bold;"&gt;""&lt;/SPAN&gt;, &lt;SPAN style="color: #008000; font-weight: bold;"&gt;""&lt;/SPAN&gt;, &lt;SPAN style="color: #0000ff;"&gt;6&lt;/SPAN&gt;)
&lt;SPAN style="color: #000080; font-weight: bold;"&gt;with &lt;/SPAN&gt;arcpy.da.UpdateCursor(combo_table, [&lt;SPAN style="color: #008000; font-weight: bold;"&gt;"EFFECTIVEHSG"&lt;/SPAN&gt;, &lt;SPAN style="color: #008000; font-weight: bold;"&gt;"HSG"&lt;/SPAN&gt;]) &lt;SPAN style="color: #000080; font-weight: bold;"&gt;as &lt;/SPAN&gt;cursor:
&lt;SPAN style="color: #000080; font-weight: bold;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for &lt;/SPAN&gt;row &lt;SPAN style="color: #000080; font-weight: bold;"&gt;in &lt;/SPAN&gt;cursor:
&lt;SPAN style="color: #000080; font-weight: bold;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if &lt;/SPAN&gt;row[&lt;SPAN style="color: #0000ff;"&gt;0&lt;/SPAN&gt;] == &lt;SPAN style="color: #0000ff;"&gt;1&lt;/SPAN&gt;:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; row[&lt;SPAN style="color: #0000ff;"&gt;1&lt;/SPAN&gt;] = &lt;SPAN style="color: #008000; font-weight: bold;"&gt;"A"
&lt;/SPAN&gt;&lt;SPAN style="color: #008000; font-weight: bold;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="color: #000080; font-weight: bold;"&gt;if &lt;/SPAN&gt;row[&lt;SPAN style="color: #0000ff;"&gt;0&lt;/SPAN&gt;] == &lt;SPAN style="color: #0000ff;"&gt;2&lt;/SPAN&gt;:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; row[&lt;SPAN style="color: #0000ff;"&gt;1&lt;/SPAN&gt;] = &lt;SPAN style="color: #008000; font-weight: bold;"&gt;"B"
&lt;/SPAN&gt;&lt;SPAN style="color: #008000; font-weight: bold;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="color: #000080; font-weight: bold;"&gt;if &lt;/SPAN&gt;row[&lt;SPAN style="color: #0000ff;"&gt;0&lt;/SPAN&gt;] == &lt;SPAN style="color: #0000ff;"&gt;3&lt;/SPAN&gt;:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; row[&lt;SPAN style="color: #0000ff;"&gt;1&lt;/SPAN&gt;] = &lt;SPAN style="color: #008000; font-weight: bold;"&gt;"C"
&lt;/SPAN&gt;&lt;SPAN style="color: #008000; font-weight: bold;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="color: #000080; font-weight: bold;"&gt;if &lt;/SPAN&gt;row[&lt;SPAN style="color: #0000ff;"&gt;0&lt;/SPAN&gt;] == &lt;SPAN style="color: #0000ff;"&gt;4&lt;/SPAN&gt;:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; row[&lt;SPAN style="color: #0000ff;"&gt;1&lt;/SPAN&gt;] = &lt;SPAN style="color: #008000; font-weight: bold;"&gt;"D"
&lt;/SPAN&gt;&lt;SPAN style="color: #008000; font-weight: bold;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;cursor.updateRow(row)

&lt;SPAN style="color: #808080; font-style: italic;"&gt;### _____________COMPARE CRITERIA_____________________ ###
&lt;/SPAN&gt;&lt;SPAN style="color: #000080; font-weight: bold;"&gt;print&lt;/SPAN&gt;(&lt;SPAN style="color: #008000; font-weight: bold;"&gt;"Creating BMP output folder..."&lt;/SPAN&gt;)
&lt;SPAN style="color: #808080; font-style: italic;"&gt;# Define location of constraint database and establish new output location
&lt;/SPAN&gt;CRIT = TabPath + &lt;SPAN style="color: #008000; font-weight: bold;"&gt;"constraints.xlsx"
&lt;/SPAN&gt;BMPFold = ProjFolder + &lt;SPAN style="color: #008000; font-weight: bold;"&gt;r"\BMP__Tables"
&lt;/SPAN&gt;&lt;SPAN style="color: #000080; font-weight: bold;"&gt;if not &lt;/SPAN&gt;os.path.exists(BMPFold):
&amp;nbsp; os.makedirs(BMPFold)
&lt;SPAN style="color: #000080; font-weight: bold;"&gt;print&lt;/SPAN&gt;(&lt;SPAN style="color: #008000; font-weight: bold;"&gt;"Loading constraint database..."&lt;/SPAN&gt;)
&lt;SPAN style="color: #808080; font-style: italic;"&gt;# Convert Excel constraint file to GIS table
&lt;/SPAN&gt;compare = arcpy.ExcelToTable_conversion(CRIT, ProjFolder + &lt;SPAN style="color: #008000; font-weight: bold;"&gt;r"\constraints"&lt;/SPAN&gt;)
fields = [&lt;SPAN style="color: #008000; font-weight: bold;"&gt;"SOIL"&lt;/SPAN&gt;, &lt;SPAN style="color: #008000; font-weight: bold;"&gt;"MAX_SLOPE"&lt;/SPAN&gt;, &lt;SPAN style="color: #008000; font-weight: bold;"&gt;"MIN_CDA"&lt;/SPAN&gt;, &lt;SPAN style="color: #008000; font-weight: bold;"&gt;"MAX_CDA"&lt;/SPAN&gt;, &lt;SPAN style="color: #008000; font-weight: bold;"&gt;"WT_SEP"&lt;/SPAN&gt;, &lt;SPAN style="color: #008000; font-weight: bold;"&gt;"WT_RELAX"&lt;/SPAN&gt;,
&lt;SPAN style="color: #008000; font-weight: bold;"&gt;"COAST_SEP"&lt;/SPAN&gt;, &lt;SPAN style="color: #008000; font-weight: bold;"&gt;"MIN_DEPTH"&lt;/SPAN&gt;, &lt;SPAN style="color: #008000; font-weight: bold;"&gt;"DEPTH_RELA"&lt;/SPAN&gt;, &lt;SPAN style="color: #008000; font-weight: bold;"&gt;"COAST_MIN_"&lt;/SPAN&gt;]

&lt;SPAN style="color: #808080; font-style: italic;"&gt;# Create output table for each drainage area
&lt;/SPAN&gt;&lt;SPAN style="color: #000080; font-weight: bold;"&gt;for &lt;/SPAN&gt;row &lt;SPAN style="color: #000080; font-weight: bold;"&gt;in &lt;/SPAN&gt;arcpy.da.SearchCursor(combo_table, [&lt;SPAN style="color: #008000; font-weight: bold;"&gt;"DARAS"&lt;/SPAN&gt;, &lt;SPAN style="color: #008000; font-weight: bold;"&gt;"HSG"&lt;/SPAN&gt;, &lt;SPAN style="color: #008000; font-weight: bold;"&gt;"MEDSLOPE"&lt;/SPAN&gt;, &lt;SPAN style="color: #008000; font-weight: bold;"&gt;"MEDWT"&lt;/SPAN&gt;]):
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.Copy_management(compare, BMPFold + &lt;SPAN style="color: #008000; font-weight: bold;"&gt;"\\" &lt;/SPAN&gt;+ &lt;SPAN style="color: #008000; font-weight: bold;"&gt;"DA" &lt;/SPAN&gt;+ &lt;SPAN style="color: #000080;"&gt;str&lt;/SPAN&gt;(row[&lt;SPAN style="color: #0000ff;"&gt;0&lt;/SPAN&gt;]) + &lt;SPAN style="color: #008000; font-weight: bold;"&gt;"HSG" &lt;/SPAN&gt;+ &lt;SPAN style="color: #000080;"&gt;str&lt;/SPAN&gt;(row[&lt;SPAN style="color: #0000ff;"&gt;1&lt;/SPAN&gt;]))
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; DAmask = arcpy.sa.SetNull(DAras, DAras, &lt;SPAN style="color: #008000; font-weight: bold;"&gt;"VALUE &amp;lt;&amp;gt; " &lt;/SPAN&gt;+ &lt;SPAN style="color: #000080;"&gt;str&lt;/SPAN&gt;(row[&lt;SPAN style="color: #0000ff;"&gt;0&lt;/SPAN&gt;]))
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.env.mask = DAmask
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.env.snapRaster = DAmask
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddField_management(BMPFold + &lt;SPAN style="color: #008000; font-weight: bold;"&gt;"\\" &lt;/SPAN&gt;+ &lt;SPAN style="color: #008000; font-weight: bold;"&gt;"DA" &lt;/SPAN&gt;+ &lt;SPAN style="color: #000080;"&gt;str&lt;/SPAN&gt;(row[&lt;SPAN style="color: #0000ff;"&gt;0&lt;/SPAN&gt;]), &lt;SPAN style="color: #008000; font-weight: bold;"&gt;"MOD"&lt;/SPAN&gt;, &lt;SPAN style="color: #008000; font-weight: bold;"&gt;"TEXT"&lt;/SPAN&gt;, &lt;SPAN style="color: #008000; font-weight: bold;"&gt;""&lt;/SPAN&gt;, &lt;SPAN style="color: #008000; font-weight: bold;"&gt;""&lt;/SPAN&gt;, &lt;SPAN style="color: #0000ff;"&gt;14&lt;/SPAN&gt;)
&lt;SPAN style="color: #000080; font-weight: bold;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for &lt;/SPAN&gt;r &lt;SPAN style="color: #000080; font-weight: bold;"&gt;in &lt;/SPAN&gt;arcpy.da.UpdateCursor(BMPFold + &lt;SPAN style="color: #008000; font-weight: bold;"&gt;"\\" &lt;/SPAN&gt;+ &lt;SPAN style="color: #008000; font-weight: bold;"&gt;"DA" &lt;/SPAN&gt;+ &lt;SPAN style="color: #000080;"&gt;str&lt;/SPAN&gt;(row[&lt;SPAN style="color: #0000ff;"&gt;0&lt;/SPAN&gt;]) + &lt;SPAN style="color: #008000; font-weight: bold;"&gt;"HSG" &lt;/SPAN&gt;+ &lt;SPAN style="color: #000080;"&gt;str&lt;/SPAN&gt;(row[&lt;SPAN style="color: #0000ff;"&gt;1&lt;/SPAN&gt;]), fields):
&lt;SPAN style="color: #000080; font-weight: bold;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if &lt;/SPAN&gt;row[&lt;SPAN style="color: #0000ff;"&gt;1&lt;/SPAN&gt;] &lt;SPAN style="color: #000080; font-weight: bold;"&gt;not in &lt;/SPAN&gt;r[&lt;SPAN style="color: #0000ff;"&gt;0&lt;/SPAN&gt;]:
&lt;SPAN style="color: #000080; font-weight: bold;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; del&lt;/SPAN&gt;(row)&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="color: #222222; font-family: arial, sans-serif; font-size: 12.8000001907349px;"&gt;&lt;/P&gt;&lt;P style="color: #222222; font-family: arial, sans-serif; font-size: 12.8000001907349px;"&gt;The problem:&amp;nbsp; I get an error saying that "NameError: name 'row' is not defined" for line 41, "if row[1] not in r[0]:".&amp;nbsp; Once the code enters the nested cursor, "row" gets wiped out and is no longer a valid parameter.&amp;nbsp; What is a workaround for this?&lt;/P&gt;&lt;P style="color: #222222; font-family: arial, sans-serif; font-size: 12.8000001907349px;"&gt;&lt;/P&gt;&lt;P style="color: #222222; font-family: arial, sans-serif; font-size: 12.8000001907349px;"&gt;EDIT:&amp;nbsp; The python syntax converter works very poorly on my computer for some reason.&amp;nbsp; Sorry.&amp;nbsp; I tried to update it so the indentations are in the right place.&amp;nbsp; If they do not appear in the correct spot, I promise they are correct in my actual code and that is not the problem.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 02:16:09 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/updating-the-rows-in-one-table-based-on-values-in/m-p/614147#M47932</guid>
      <dc:creator>RachaelJohnson</dc:creator>
      <dc:date>2021-12-12T02:16:09Z</dc:date>
    </item>
    <item>
      <title>Re: Updating the rows in one table based on values in another table or using nested cursors</title>
      <link>https://community.esri.com/t5/python-questions/updating-the-rows-in-one-table-based-on-values-in/m-p/614148#M47933</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;​this may just be an error when copying your Python to your question, but check (and modify in original post) your indentation, especially starting in row 5-13 and 36-37.&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;i'm not at a location that I can test the code,but that will be the first thing to check.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 21 Apr 2015 13:36:23 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/updating-the-rows-in-one-table-based-on-values-in/m-p/614148#M47933</guid>
      <dc:creator>RebeccaStrauch__GISP</dc:creator>
      <dc:date>2015-04-21T13:36:23Z</dc:date>
    </item>
    <item>
      <title>Re: Updating the rows in one table based on values in another table or using nested cursors</title>
      <link>https://community.esri.com/t5/python-questions/updating-the-rows-in-one-table-based-on-values-in/m-p/614149#M47934</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yes, thank you, I actually started correcting that before you even posted!&amp;nbsp; It loses the indents when I copy it over and I always forget. I am trying to correct it but the last few indents don't want to stick for some reason.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 21 Apr 2015 13:57:11 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/updating-the-rows-in-one-table-based-on-values-in/m-p/614149#M47934</guid>
      <dc:creator>RachaelJohnson</dc:creator>
      <dc:date>2015-04-21T13:57:11Z</dc:date>
    </item>
    <item>
      <title>Re: Updating the rows in one table based on values in another table or using nested cursors</title>
      <link>https://community.esri.com/t5/python-questions/updating-the-rows-in-one-table-based-on-values-in/m-p/614150#M47935</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;row is use in many part of your code.&amp;nbsp; Which specific line is throwing the error?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Also, do not use nested cursors.&amp;nbsp; They are horribly inefficient and in my opinion should never be used.&amp;nbsp; Instead first use a cursor to load the entire source you want to match into a dictionary and then run an updatecursor on the data that needs to match it using the dictionary to compare the values.&amp;nbsp; See my blog on the subject &lt;A _jive_internal="true" href="https://community.esri.com/blogs/richard_fairhurst/2014/11/08/turbo-charging-data-manipulation-with-python-cursors-and-dictionaries"&gt;here&lt;/A&gt; for some ideas of how this can be set up.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 21 Apr 2015 14:26:37 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/updating-the-rows-in-one-table-based-on-values-in/m-p/614150#M47935</guid>
      <dc:creator>RichardFairhurst</dc:creator>
      <dc:date>2015-04-21T14:26:37Z</dc:date>
    </item>
    <item>
      <title>Re: Updating the rows in one table based on values in another table or using nested cursors</title>
      <link>https://community.esri.com/t5/python-questions/updating-the-rows-in-one-table-based-on-values-in/m-p/614151#M47936</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The last part, the nested cursor, is throwing the error.&amp;nbsp; I always use "row" in my code for cursors (except in this nested cursor case).&amp;nbsp; Is that a bad thing?&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;SPAN style="color: #000080; font-weight: bold;"&gt;for &lt;/SPAN&gt;r &lt;SPAN style="color: #000080; font-weight: bold;"&gt;in &lt;/SPAN&gt;arcpy.da.UpdateCursor(BMPFold + &lt;SPAN style="color: #008000; font-weight: bold;"&gt;"\\" &lt;/SPAN&gt;+ &lt;SPAN style="color: #008000; font-weight: bold;"&gt;"DA" &lt;/SPAN&gt;+ &lt;SPAN style="color: #000080;"&gt;str&lt;/SPAN&gt;(row[&lt;SPAN style="color: #0000ff;"&gt;0&lt;/SPAN&gt;]) + &lt;SPAN style="color: #008000; font-weight: bold;"&gt;"HSG" &lt;/SPAN&gt;+ &lt;SPAN style="color: #000080;"&gt;str&lt;/SPAN&gt;(row[&lt;SPAN style="color: #0000ff;"&gt;1&lt;/SPAN&gt;]), fields):
&amp;nbsp; &lt;SPAN style="color: #000080; font-weight: bold;"&gt;if &lt;/SPAN&gt;row[&lt;SPAN style="color: #0000ff;"&gt;1&lt;/SPAN&gt;] &lt;SPAN style="color: #000080; font-weight: bold;"&gt;not in &lt;/SPAN&gt;r[&lt;SPAN style="color: #0000ff;"&gt;0&lt;/SPAN&gt;]:
&lt;SPAN style="color: #000080; font-weight: bold;"&gt;del&lt;/SPAN&gt;(row)&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I thought it might be inefficient but I didn't have a better way to do it.&amp;nbsp; I'll check out your blog post and see what I can do with a dictionary instead.&amp;nbsp; Thank you.&amp;nbsp; I will probably have some questions later on since I've never used a dictionary before.&lt;SPAN style="font-weight: inherit; font-style: inherit; color: black; font-size: 9pt !important; background-color: inherit;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 02:16:11 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/updating-the-rows-in-one-table-based-on-values-in/m-p/614151#M47936</guid>
      <dc:creator>RachaelJohnson</dc:creator>
      <dc:date>2021-12-12T02:16:11Z</dc:date>
    </item>
    <item>
      <title>Re: Updating the rows in one table based on values in another table or using nested cursors</title>
      <link>https://community.esri.com/t5/python-questions/updating-the-rows-in-one-table-based-on-values-in/m-p/614152#M47937</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Using row or r is fine.&amp;nbsp; I think the problem is that the comparison continues after the row has been deleted.&amp;nbsp; Once deleted, row would be undefined for the comparison to the next r[0] value.&amp;nbsp; You would need to break out of the for loop once the del(row) operation takes place.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;That also raises the question about the comparison logic.&amp;nbsp; If you do not query the table for any specific records, than I would expect many records to not match your row values, and the row would virtually always be deleted.&amp;nbsp; A dictionary would help with this, since doing a if not row[0] in dict: compares to all the of dictionary keys you previously loaded from the entire table at once, not to just one row at a time in the comparison table.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 21 Apr 2015 14:45:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/updating-the-rows-in-one-table-based-on-values-in/m-p/614152#M47937</guid>
      <dc:creator>RichardFairhurst</dc:creator>
      <dc:date>2015-04-21T14:45:50Z</dc:date>
    </item>
    <item>
      <title>Re: Updating the rows in one table based on values in another table or using nested cursors</title>
      <link>https://community.esri.com/t5/python-questions/updating-the-rows-in-one-table-based-on-values-in/m-p/614153#M47938</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I added "break" to my code and now it loops through all the expected combinations of drainage zone and soil type and copies the constraint table for each! But, I found that it didn't delete the rows in the table. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;row[1] = "HSG" from combo_table&lt;/P&gt;&lt;P&gt;r[0] = "SOIL" from table DA1HSGD&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;SPAN style="color: #808080; font-style: italic;"&gt;# Create output table for each drainage area
&lt;/SPAN&gt;&lt;SPAN style="color: #000080; font-weight: bold;"&gt;for &lt;/SPAN&gt;row &lt;SPAN style="color: #000080; font-weight: bold;"&gt;in &lt;/SPAN&gt;arcpy.da.SearchCursor(combo_table, [&lt;SPAN style="color: #008000; font-weight: bold;"&gt;"DARAS"&lt;/SPAN&gt;, &lt;SPAN style="color: #008000; font-weight: bold;"&gt;"HSG"&lt;/SPAN&gt;, &lt;SPAN style="color: #008000; font-weight: bold;"&gt;"MEDSLOPE"&lt;/SPAN&gt;, &lt;SPAN style="color: #008000; font-weight: bold;"&gt;"MEDWT"&lt;/SPAN&gt;]):
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="color: #000080; font-weight: bold;"&gt;print&lt;/SPAN&gt;(&lt;SPAN style="color: #008000; font-weight: bold;"&gt;"Saving constraint table for DA " &lt;/SPAN&gt;+ &lt;SPAN style="color: #000080;"&gt;str&lt;/SPAN&gt;(row[&lt;SPAN style="color: #0000ff;"&gt;0&lt;/SPAN&gt;]) + &lt;SPAN style="color: #008000; font-weight: bold;"&gt;" and HSG " &lt;/SPAN&gt;+ &lt;SPAN style="color: #000080;"&gt;str&lt;/SPAN&gt;(row[&lt;SPAN style="color: #0000ff;"&gt;1&lt;/SPAN&gt;]) + &lt;SPAN style="color: #008000; font-weight: bold;"&gt;"..."&lt;/SPAN&gt;)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.Copy_management(compare, BMPFold + &lt;SPAN style="color: #008000; font-weight: bold;"&gt;"\\" &lt;/SPAN&gt;+ &lt;SPAN style="color: #008000; font-weight: bold;"&gt;"DA" &lt;/SPAN&gt;+ &lt;SPAN style="color: #000080;"&gt;str&lt;/SPAN&gt;(row[&lt;SPAN style="color: #0000ff;"&gt;0&lt;/SPAN&gt;]) + &lt;SPAN style="color: #008000; font-weight: bold;"&gt;"HSG" &lt;/SPAN&gt;+ &lt;SPAN style="color: #000080;"&gt;str&lt;/SPAN&gt;(row[&lt;SPAN style="color: #0000ff;"&gt;1&lt;/SPAN&gt;]))
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="color: #808080; font-style: italic;"&gt;# DAmask = arcpy.sa.SetNull(DAras, DAras, "VALUE &amp;lt;&amp;gt; " + str(row[0]))
&lt;/SPAN&gt;&lt;SPAN style="color: #808080; font-style: italic;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # arcpy.env.mask = DAmask
&lt;/SPAN&gt;&lt;SPAN style="color: #808080; font-style: italic;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # arcpy.env.snapRaster = DAmask
&lt;/SPAN&gt;&lt;SPAN style="color: #808080; font-style: italic;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;arcpy.AddField_management(BMPFold + &lt;SPAN style="color: #008000; font-weight: bold;"&gt;"\\" &lt;/SPAN&gt;+ &lt;SPAN style="color: #008000; font-weight: bold;"&gt;"DA" &lt;/SPAN&gt;+ &lt;SPAN style="color: #000080;"&gt;str&lt;/SPAN&gt;(row[&lt;SPAN style="color: #0000ff;"&gt;0&lt;/SPAN&gt;])&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; + &lt;SPAN style="color: #008000; font-weight: bold;"&gt;"HSG" &lt;/SPAN&gt;+ &lt;SPAN style="color: #000080;"&gt;str&lt;/SPAN&gt;(row[&lt;SPAN style="color: #0000ff;"&gt;1&lt;/SPAN&gt;]), &lt;SPAN style="color: #008000; font-weight: bold;"&gt;"MOD"&lt;/SPAN&gt;, &lt;SPAN style="color: #008000; font-weight: bold;"&gt;"TEXT"&lt;/SPAN&gt;, &lt;SPAN style="color: #008000; font-weight: bold;"&gt;""&lt;/SPAN&gt;, &lt;SPAN style="color: #008000; font-weight: bold;"&gt;""&lt;/SPAN&gt;, &lt;SPAN style="color: #0000ff;"&gt;14&lt;/SPAN&gt;)

&amp;nbsp; &lt;SPAN style="color: #808080; font-style: italic;"&gt;# Check constraints against the site values and remove infeasible stormwater practices
&lt;/SPAN&gt;&lt;SPAN style="color: #808080; font-style: italic;"&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="color: #000080; font-weight: bold;"&gt;for &lt;/SPAN&gt;r &lt;SPAN style="color: #000080; font-weight: bold;"&gt;in &lt;/SPAN&gt;arcpy.da.UpdateCursor(BMPFold + &lt;SPAN style="color: #008000; font-weight: bold;"&gt;"\\" &lt;/SPAN&gt;+ &lt;SPAN style="color: #008000; font-weight: bold;"&gt;"DA" &lt;/SPAN&gt;+ &lt;SPAN style="color: #000080;"&gt;str&lt;/SPAN&gt;(row[&lt;SPAN style="color: #0000ff;"&gt;0&lt;/SPAN&gt;]) + &lt;SPAN style="color: #008000; font-weight: bold;"&gt;"HSG" &lt;/SPAN&gt;+ &lt;SPAN style="color: #000080;"&gt;str&lt;/SPAN&gt;(row[&lt;SPAN style="color: #0000ff;"&gt;1&lt;/SPAN&gt;]), fields):
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="color: #000080; font-weight: bold;"&gt;print&lt;/SPAN&gt;(&lt;SPAN style="color: #008000; font-weight: bold;"&gt;"Removing incompatible soil types..."&lt;/SPAN&gt;)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="color: #000080; font-weight: bold;"&gt;if &lt;/SPAN&gt;row[&lt;SPAN style="color: #0000ff;"&gt;1&lt;/SPAN&gt;] &lt;SPAN style="color: #000080; font-weight: bold;"&gt;not in &lt;/SPAN&gt;r[&lt;SPAN style="color: #0000ff;"&gt;0&lt;/SPAN&gt;]:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="color: #000080; font-weight: bold;"&gt;del&lt;/SPAN&gt;(row)
&lt;SPAN style="color: #000080; font-weight: bold;"&gt;break&lt;/SPAN&gt;&lt;/PRE&gt;&lt;P&gt;It saves the tables as all lowercase and I am calling an uppercase version.&amp;nbsp; Could that be the problem?&amp;nbsp; How do I convert row[1] into lowercase for the purpose of calling the correct table?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here are my tables in case it helps to see them:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG alt="combo_table.jpg" class="image-1 jive-image" height="188" src="https://community.esri.com/legacyfs/online/87537_combo_table.jpg" style="width: 501px; height: 188.279032258065px;" width="501" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG alt="DA1HSGD.jpg" class="image-2 jive-image" height="463" src="https://community.esri.com/legacyfs/online/87538_DA1HSGD.jpg" style="width: 903px; height: 463.151612903226px;" width="903" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 02:16:14 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/updating-the-rows-in-one-table-based-on-values-in/m-p/614153#M47938</guid>
      <dc:creator>RachaelJohnson</dc:creator>
      <dc:date>2021-12-12T02:16:14Z</dc:date>
    </item>
    <item>
      <title>Re: Updating the rows in one table based on values in another table or using nested cursors</title>
      <link>https://community.esri.com/t5/python-questions/updating-the-rows-in-one-table-based-on-values-in/m-p/614154#M47939</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The problem is that you cannot use del(row).&amp;nbsp; You have to use cursor.deleteRow(row).&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 21 Apr 2015 15:20:01 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/updating-the-rows-in-one-table-based-on-values-in/m-p/614154#M47939</guid>
      <dc:creator>RichardFairhurst</dc:creator>
      <dc:date>2015-04-21T15:20:01Z</dc:date>
    </item>
    <item>
      <title>Re: Updating the rows in one table based on values in another table or using nested cursors</title>
      <link>https://community.esri.com/t5/python-questions/updating-the-rows-in-one-table-based-on-values-in/m-p/614155#M47940</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Ah! I see. I got it to work with this code. Thank you!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;SPAN style="color: #808080; font-style: italic;"&gt;# Create output table for each drainage area
&lt;/SPAN&gt;&lt;SPAN style="color: #000080; font-weight: bold;"&gt;for &lt;/SPAN&gt;row &lt;SPAN style="color: #000080; font-weight: bold;"&gt;in &lt;/SPAN&gt;arcpy.da.SearchCursor(combo_table, [&lt;SPAN style="color: #008000; font-weight: bold;"&gt;"DARAS"&lt;/SPAN&gt;, &lt;SPAN style="color: #008000; font-weight: bold;"&gt;"HSG"&lt;/SPAN&gt;, &lt;SPAN style="color: #008000; font-weight: bold;"&gt;"MEDSLOPE"&lt;/SPAN&gt;, &lt;SPAN style="color: #008000; font-weight: bold;"&gt;"MEDWT"&lt;/SPAN&gt;]):
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="color: #000080; font-weight: bold;"&gt;print&lt;/SPAN&gt;(&lt;SPAN style="color: #008000; font-weight: bold;"&gt;"Saving constraint table for DA " &lt;/SPAN&gt;+ &lt;SPAN style="color: #000080;"&gt;str&lt;/SPAN&gt;(row[&lt;SPAN style="color: #0000ff;"&gt;0&lt;/SPAN&gt;]) + &lt;SPAN style="color: #008000; font-weight: bold;"&gt;" and HSG " &lt;/SPAN&gt;+ &lt;SPAN style="color: #000080;"&gt;str&lt;/SPAN&gt;(row[&lt;SPAN style="color: #0000ff;"&gt;1&lt;/SPAN&gt;]) + &lt;SPAN style="color: #008000; font-weight: bold;"&gt;"..."&lt;/SPAN&gt;)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.Copy_management(compare, BMPFold + &lt;SPAN style="color: #008000; font-weight: bold;"&gt;"\\" &lt;/SPAN&gt;+ &lt;SPAN style="color: #008000; font-weight: bold;"&gt;"DA" &lt;/SPAN&gt;+ &lt;SPAN style="color: #000080;"&gt;str&lt;/SPAN&gt;(row[&lt;SPAN style="color: #0000ff;"&gt;0&lt;/SPAN&gt;]) + &lt;SPAN style="color: #008000; font-weight: bold;"&gt;"HSG" &lt;/SPAN&gt;+ &lt;SPAN style="color: #000080;"&gt;str&lt;/SPAN&gt;(row[&lt;SPAN style="color: #0000ff;"&gt;1&lt;/SPAN&gt;]))
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="color: #808080; font-style: italic;"&gt;# DAmask = arcpy.sa.SetNull(DAras, DAras, "VALUE &amp;lt;&amp;gt; " + str(row[0]))
&lt;/SPAN&gt;&lt;SPAN style="color: #808080; font-style: italic;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # arcpy.env.mask = DAmask
&lt;/SPAN&gt;&lt;SPAN style="color: #808080; font-style: italic;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # arcpy.env.snapRaster = DAmask
&lt;/SPAN&gt;&lt;SPAN style="color: #808080; font-style: italic;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;arcpy.AddField_management(BMPFold + &lt;SPAN style="color: #008000; font-weight: bold;"&gt;"\\" &lt;/SPAN&gt;+ &lt;SPAN style="color: #008000; font-weight: bold;"&gt;"DA" &lt;/SPAN&gt;+ &lt;SPAN style="color: #000080;"&gt;str&lt;/SPAN&gt;(row[&lt;SPAN style="color: #0000ff;"&gt;0&lt;/SPAN&gt;])&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; + &lt;SPAN style="color: #008000; font-weight: bold;"&gt;"HSG" &lt;/SPAN&gt;+ &lt;SPAN style="color: #000080;"&gt;str&lt;/SPAN&gt;(row[&lt;SPAN style="color: #0000ff;"&gt;1&lt;/SPAN&gt;]), &lt;SPAN style="color: #008000; font-weight: bold;"&gt;"MOD"&lt;/SPAN&gt;, &lt;SPAN style="color: #008000; font-weight: bold;"&gt;"TEXT"&lt;/SPAN&gt;, &lt;SPAN style="color: #008000; font-weight: bold;"&gt;""&lt;/SPAN&gt;, &lt;SPAN style="color: #008000; font-weight: bold;"&gt;""&lt;/SPAN&gt;, &lt;SPAN style="color: #0000ff;"&gt;14&lt;/SPAN&gt;)

&amp;nbsp; &lt;SPAN style="color: #808080; font-style: italic;"&gt;# Check constraints against the site values and remove infeasible stormwater practices
&lt;/SPAN&gt;&lt;SPAN style="color: #808080; font-style: italic;"&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="color: #000080; font-weight: bold;"&gt;with &lt;/SPAN&gt;arcpy.da.UpdateCursor(BMPFold + &lt;SPAN style="color: #008000; font-weight: bold;"&gt;"\\" &lt;/SPAN&gt;+ &lt;SPAN style="color: #008000; font-weight: bold;"&gt;"da" &lt;/SPAN&gt;+ &lt;SPAN style="color: #000080;"&gt;str&lt;/SPAN&gt;(row[&lt;SPAN style="color: #0000ff;"&gt;0&lt;/SPAN&gt;]) + &lt;SPAN style="color: #008000; font-weight: bold;"&gt;"hsg" &lt;/SPAN&gt;+ &lt;SPAN style="color: #000080;"&gt;str&lt;/SPAN&gt;(row[&lt;SPAN style="color: #0000ff;"&gt;1&lt;/SPAN&gt;]), fields) &lt;SPAN style="color: #000080; font-weight: bold;"&gt;as &lt;/SPAN&gt;cursor:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="color: #000080; font-weight: bold;"&gt;for &lt;/SPAN&gt;r &lt;SPAN style="color: #000080; font-weight: bold;"&gt;in &lt;/SPAN&gt;cursor:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="color: #000080; font-weight: bold;"&gt;print&lt;/SPAN&gt;(&lt;SPAN style="color: #008000; font-weight: bold;"&gt;"Checking for incompatible soil types..."&lt;/SPAN&gt;)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="color: #000080; font-weight: bold;"&gt;if &lt;/SPAN&gt;row[&lt;SPAN style="color: #0000ff;"&gt;1&lt;/SPAN&gt;] &lt;SPAN style="color: #000080; font-weight: bold;"&gt;not in &lt;/SPAN&gt;r[&lt;SPAN style="color: #0000ff;"&gt;0&lt;/SPAN&gt;]:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="color: #000080; font-weight: bold;"&gt;print&lt;/SPAN&gt;(&lt;SPAN style="color: #008000; font-weight: bold;"&gt;"Removing " &lt;/SPAN&gt;+ &lt;SPAN style="color: #000080;"&gt;str&lt;/SPAN&gt;(r[&lt;SPAN style="color: #0000ff;"&gt;10&lt;/SPAN&gt;]) + &lt;SPAN style="color: #008000; font-weight: bold;"&gt;" based on soil type..."&lt;/SPAN&gt;)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; cursor.deleteRow()&lt;/PRE&gt;&lt;P&gt;So, I just now noticed the second part of your reply:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;&lt;EM&gt;"That also raises the question about the comparison logic.&amp;nbsp; If you do not query the table for any specific records, than I would expect many records to not match your row values, and the row would virtually always be deleted.&amp;nbsp; A dictionary would help with this, since doing a if not row[0] in dict: compares to all the of dictionary keys you previously loaded from the entire table at once, not to just one row at a time in the comparison table."&lt;/EM&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;Before I move on to trying to construct a dictionary, I want to be sure it's going to do what I want it to do.&amp;nbsp; It sounds like you're saying that constructing a dictionary will compare all the rows in the constraint table to the combo_table dictionary all at once and remove rows from the constraint table in a group rather than row-by-row.&amp;nbsp; Right?&amp;nbsp; For each row in my Combo_Table, I have a separate constraint file that I want to be edited.&amp;nbsp; Each constraint table should be checked against the values in just one row of the combo table, not all of them at once.&amp;nbsp; &lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 02:16:17 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/updating-the-rows-in-one-table-based-on-values-in/m-p/614155#M47940</guid>
      <dc:creator>RachaelJohnson</dc:creator>
      <dc:date>2021-12-12T02:16:17Z</dc:date>
    </item>
  </channel>
</rss>

