<?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: Replace Values from One Table with Values from Another? in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/replace-values-from-one-table-with-values-from/m-p/294339#M22783</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Why not use a join?&amp;nbsp; It will do that matching for you.&amp;nbsp; Then cycle through the fields doing a field calc to move the data over.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 04 Dec 2019 17:13:36 GMT</pubDate>
    <dc:creator>DougBrowning</dc:creator>
    <dc:date>2019-12-04T17:13:36Z</dc:date>
    <item>
      <title>Replace Values from One Table with Values from Another?</title>
      <link>https://community.esri.com/t5/python-questions/replace-values-from-one-table-with-values-from/m-p/294337#M22781</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 style="margin: 0cm 0cm 10pt;"&gt;&lt;SPAN style="color: #000000; font-family: Calibri; font-size: medium;"&gt;I’ve given myself a bit of a personal challenge at work to try and create a Python script that can help streamline the process of replacing multiple rows in an attribute table. I have an assignment that requires me to update almost 3,000 entries of data in a table. I could do it manually, but Python seems purpose-built for this kind of thing. I’m hitting a couple of road blocks that I hope can be clarified.&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin: 0cm 0cm 10pt;"&gt;&lt;SPAN style="color: #000000; font-size: medium; font-family: Calibri; "&gt;What I’m trying to accomplish is easy in theory: a script that will read the values of a certain column in a table (these are essentially unique identifier numbers), compare them to the values in a column in a second table, and if those values are equivalent, replace them with values from another column. Here's how I'm visualizing it:&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin: 0cm 0cm 10pt;"&gt;&lt;SPAN style="color: #000000; font-size: medium; font-family: Calibri; "&gt;Read&amp;nbsp;each row value of column C in table 1&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin: 0cm 0cm 10pt;"&gt;&lt;SPAN style="color: #000000; font-size: medium; font-family: Calibri; "&gt;Read each row value of column C in table 2&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin: 0cm 0cm 10pt;"&gt;&lt;SPAN style="color: #000000; font-size: medium; font-family: Calibri; "&gt;See if the&amp;nbsp;identifier numbers&amp;nbsp;are exactly the same (==). If so, pluck the row values from column D in table 2 and overwrite table 1, column D's row values&amp;nbsp;with them. Leave any values that do not match alone.&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin: 0cm 0cm 10pt;"&gt;&lt;SPAN style="color: #000000; font-size: medium; font-family: Calibri; "&gt;---&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin: 0cm 0cm 10pt;"&gt;&lt;SPAN style="color: #000000; font-size: medium; font-family: Calibri; "&gt;Here's how I'd &lt;EM&gt;think &lt;/EM&gt;it works in Python, but I'm rusty and need some help stringing the ideas together:&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin: 0cm 0cm 10pt;"&gt;&lt;SPAN style="color: #000000; font-size: medium; font-family: Calibri; "&gt;Import arcpy, Import env&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin: 0cm 0cm 10pt;"&gt;&lt;SPAN style="color: #000000; font-size: medium; font-family: Calibri; "&gt;Table2 = "C:/Documents/Table2.csv"&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin: 0cm 0cm 10pt;"&gt;&lt;SPAN style="color: #000000; font-size: medium; font-family: Calibri; "&gt;For entry in Table1:&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin: 0cm 0cm 10pt;"&gt;&lt;SPAN style="color: #000000; font-size: medium; font-family: Calibri; "&gt;With arcpy.da.UpdateCursor(Table1, ColumnD) as cursor:&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin: 0cm 0cm 10pt;"&gt;&lt;SPAN style="color: #000000; font-size: medium; font-family: Calibri; "&gt;If Table2Col == Table1Col:&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin: 0cm 0cm 10pt;"&gt;&lt;SPAN style="color: #000000; font-size: medium; font-family: Calibri; "&gt;arcpy.updateRow()&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin: 0cm 0cm 10pt;"&gt;&lt;SPAN style="color: #000000; font-size: medium; font-family: Calibri; "&gt;I know this is pretty off, but it's about as far as I can muster at the moment. How do I get this code from theoretical to functional? In particular, how can I get Python to refer to one table's column, compare it to another, and if the row values are equivalent, replace the values in another column? Also, would the Boolean operator help keep any entries that do not match from being altered or deleted? &lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 27 Nov 2019 19:28:10 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/replace-values-from-one-table-with-values-from/m-p/294337#M22781</guid>
      <dc:creator>IsaiahBarker</dc:creator>
      <dc:date>2019-11-27T19:28:10Z</dc:date>
    </item>
    <item>
      <title>Re: Replace Values from One Table with Values from Another?</title>
      <link>https://community.esri.com/t5/python-questions/replace-values-from-one-table-with-values-from/m-p/294338#M22782</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Have you checked out: &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;Turbo Charging Data Manipulation with Python Cursors and Dictionaries&lt;/A&gt;&amp;nbsp;?&lt;/P&gt;&lt;P&gt;From your description, it sounds like you want to do what is described in the article.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 27 Nov 2019 19:43:09 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/replace-values-from-one-table-with-values-from/m-p/294338#M22782</guid>
      <dc:creator>RandyBurton</dc:creator>
      <dc:date>2019-11-27T19:43:09Z</dc:date>
    </item>
    <item>
      <title>Re: Replace Values from One Table with Values from Another?</title>
      <link>https://community.esri.com/t5/python-questions/replace-values-from-one-table-with-values-from/m-p/294339#M22783</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Why not use a join?&amp;nbsp; It will do that matching for you.&amp;nbsp; Then cycle through the fields doing a field calc to move the data over.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 04 Dec 2019 17:13:36 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/replace-values-from-one-table-with-values-from/m-p/294339#M22783</guid>
      <dc:creator>DougBrowning</dc:creator>
      <dc:date>2019-12-04T17:13:36Z</dc:date>
    </item>
  </channel>
</rss>

