<?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: Using Python Dictionaries with Update Cursors instead of &amp;quot;Join and Calculate&amp;quot; in Transportation Questions</title>
    <link>https://community.esri.com/t5/transportation-questions/using-python-dictionaries-with-update-cursors/m-p/514276#M1701</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Original User: Caleb1987&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Oops, I did not attach the correct help document! Here it is! this will better explain things.&amp;nbsp; Sorry!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 15 Nov 2012 20:04:16 GMT</pubDate>
    <dc:creator>Anonymous User</dc:creator>
    <dc:date>2012-11-15T20:04:16Z</dc:date>
    <item>
      <title>Using Python Dictionaries with Update Cursors instead of "Join and Calculate"</title>
      <link>https://community.esri.com/t5/transportation-questions/using-python-dictionaries-with-update-cursors/m-p/514275#M1700</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;As with many others, I was frustrated with the amount of time it takes to use the "Add Join" tool and "Calculate field" tool to get values from one table into another.&amp;nbsp; To increase the performance, I started playing around with dictionaries and saw that many other people have done this as well to create a dictionary to use with an update cursor so that I do not have to do the "join and calculate" method.&amp;nbsp; The dictionary method is a very efficient way to update records (since update cursors cannot work with joined tables) and performs this operation about 100x times faster.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I decided to write a couple functions that will use the dictionary and update cursor method to update tables since it is a LOT faster.&amp;nbsp; I wrote one function that will create a dictionary and update one field in an attribute table based on a dictionary created from another table somewhere else on disk.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Next I created another function that will accept a list of fields to update in the source table, and a list of value fields from another table (join table) that will be used to update the fields in the source table.&amp;nbsp; It creates a new dictionary for each join table field and updates all input fields in the source table.&amp;nbsp; The only catch with this is there has to be the same amount of update fields and value fields from both tables.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Anyways, these two functions work great and I am attaching the script that contains them to this post in case anyone is interested.&amp;nbsp; Also attached is the tool help documentation I hastily put together. They have already saved me a ton of time.&amp;nbsp; There are two versions, one for Arc 10.0 and one for 10.1.&amp;nbsp; The only difference is that the 10.1 version uses the da cursors and is faster than the 10.0 version for that reason.&amp;nbsp; Enjoy!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;EDIT: Just took another look at my script and there is one thing I forgot to take out:&lt;/SPAN&gt;&lt;BR /&gt;&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; fieldsDict[field] = join_values[ind]&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;This line can be removed.&amp;nbsp; It won't hurt anything by leaving it in, but if anyone is wondering why it is in there, just ignore that, I forgot to take it out after testing.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 15 Nov 2012 18:06:54 GMT</pubDate>
      <guid>https://community.esri.com/t5/transportation-questions/using-python-dictionaries-with-update-cursors/m-p/514275#M1700</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2012-11-15T18:06:54Z</dc:date>
    </item>
    <item>
      <title>Re: Using Python Dictionaries with Update Cursors instead of "Join and Calculate"</title>
      <link>https://community.esri.com/t5/transportation-questions/using-python-dictionaries-with-update-cursors/m-p/514276#M1701</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Original User: Caleb1987&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Oops, I did not attach the correct help document! Here it is! this will better explain things.&amp;nbsp; Sorry!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 15 Nov 2012 20:04:16 GMT</pubDate>
      <guid>https://community.esri.com/t5/transportation-questions/using-python-dictionaries-with-update-cursors/m-p/514276#M1701</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2012-11-15T20:04:16Z</dc:date>
    </item>
  </channel>
</rss>

