<?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: How can I add values to this  Python dictionary more efficiently? in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/how-can-i-add-values-to-this-python-dictionary/m-p/445140#M34857</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You are looping over the entire data set with the cursor for each &lt;SPAN style="font-family: courier new, courier, monospace;"&gt;prop&lt;/SPAN&gt;.&amp;nbsp; I am guessing it takes roughly 40 seconds to loop through the entire data and do no processing of the data.&amp;nbsp; There is a way to restructure the code to make it much more efficient, I just don't have the time at the moment to dive into it.&amp;nbsp; What you could try with little code refactoring is to add an SQL WHERE clause on the search cursor to limit the records being returned to only those of the &lt;SPAN style="font-family: courier new, courier, monospace;"&gt;prop&lt;/SPAN&gt; you are processing.&amp;nbsp; It is much faster for the back-end data store to filter records than pass all the records to the client and filter.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 08 Feb 2019 22:18:46 GMT</pubDate>
    <dc:creator>JoshuaBixby</dc:creator>
    <dc:date>2019-02-08T22:18:46Z</dc:date>
    <item>
      <title>How can I add values to this  Python dictionary more efficiently?</title>
      <link>https://community.esri.com/t5/python-questions/how-can-i-add-values-to-this-python-dictionary/m-p/445138#M34855</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I've been building on some principles from &lt;A href="https://community.esri.com/migration-blogpost/1456" target="_blank"&gt;Richard Fairhurst's Blog&lt;/A&gt;&lt;A href="https://community.esri.com/blogs/richard_fairhurst/2014/11/08/turbo-charging-data-manipulation-with-python-cursors-and-dictionaries" target="_blank"&gt;/blogs/richard_fairhurst/2014/11/08/turbo-charging-data-manipulation-with-python-cursors-and-dictionaries&lt;/A&gt; My goal is to map the average daily well volume for the past 90 days.&amp;nbsp; I have a table of daily volumes for about 1,300 wells.&amp;nbsp; There are several years worth of records in the table.&amp;nbsp; I also have a Python dictionary.&amp;nbsp; The keys in the dictionary are the unique identifier for each well represented in the table.&amp;nbsp; The values in the dictionary start as empty lists.&amp;nbsp; The following block of code&amp;nbsp;populates the dictionary values with the daily volume values from the past 92 days for each well.&amp;nbsp; The code works, but it takes approximately 40 seconds for each well.&amp;nbsp; How can I modify the code to improve performance?&amp;nbsp; Please see the code and comments below.&amp;nbsp; Any suggestions would be greatly appreciated.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;i &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="number token"&gt;0&lt;/SPAN&gt; &lt;SPAN class="comment token"&gt;# This is a counter for testing purposes&lt;/SPAN&gt;
table &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; acDaily &lt;SPAN class="comment token"&gt;# This is a SQL Server database table of daily water volumes.  There are ~1300 wells represented in the table, each with daily records covering several years.&lt;/SPAN&gt;
fields &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;'PROPNUM'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;'D_DATE'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;'WATER'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt; &lt;SPAN class="comment token"&gt;# PROPNUM is the unique identifier for each well in acDaily, D_DATE is the date of the daily volume, and WATER is the volume of produced water.&lt;/SPAN&gt;

&lt;SPAN class="keyword token"&gt;for&lt;/SPAN&gt; prop &lt;SPAN class="keyword token"&gt;in&lt;/SPAN&gt; propNumDict&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt; &lt;SPAN class="comment token"&gt;# Iterate through each item in propNumDict.  propNumDict is a Python dictionary with keys that are the unique values in the acDaily PROPNUM field.  The dictionary values start as empty lists.&lt;/SPAN&gt;
    i &lt;SPAN class="operator token"&gt;+=&lt;/SPAN&gt; &lt;SPAN class="number token"&gt;1&lt;/SPAN&gt;
    &lt;SPAN class="keyword token"&gt;print&lt;/SPAN&gt; str&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;i&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;+&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;" - "&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;+&lt;/SPAN&gt; strftime&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"%Y-%m-%d %H:%M:%S"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;  &lt;SPAN class="comment token"&gt;# This is used to time the duration of each iteration, which is currently ~40 seconds.&lt;/SPAN&gt;
    &lt;SPAN class="keyword token"&gt;if&lt;/SPAN&gt; i &lt;SPAN class="operator token"&gt;&amp;gt;&lt;/SPAN&gt; &lt;SPAN class="number token"&gt;2&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
        &lt;SPAN class="keyword token"&gt;break&lt;/SPAN&gt;
    &lt;SPAN class="keyword token"&gt;else&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
        &lt;SPAN class="keyword token"&gt;with&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;da&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;SearchCursor&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;table&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; fields&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt; &lt;SPAN class="keyword token"&gt;as&lt;/SPAN&gt; cursor&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt; &lt;SPAN class="comment token"&gt;# Use a search cursor to go through the records in acDaily and if the PROPNUM matches the key in propNumDict and the records are from the past 92 days, add the water volume value to the dictionary.&lt;/SPAN&gt;
            &lt;SPAN class="keyword token"&gt;for&lt;/SPAN&gt; row &lt;SPAN class="keyword token"&gt;in&lt;/SPAN&gt; cursor&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
                &lt;SPAN class="keyword token"&gt;if&lt;/SPAN&gt; row&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;0&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;==&lt;/SPAN&gt; prop &lt;SPAN class="operator token"&gt;and&lt;/SPAN&gt; row&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;1&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;&amp;gt;&lt;/SPAN&gt; tMinus92&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt; &lt;SPAN class="comment token"&gt;# tMinus92 is a variable defined as datetime.datetime.today() - timedelta(days = 92).  It takes two days for the data to make it into this table.&lt;/SPAN&gt;
                    propNumDict&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;prop&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;append&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;row&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;2&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;

&lt;SPAN class="keyword token"&gt;print&lt;/SPAN&gt; propNumDict
&lt;SPAN class="keyword token"&gt;print&lt;/SPAN&gt; strftime&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"%Y-%m-%d %H:%M:%S"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍&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;/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;After the propNumDict dictionary is populated, I have another block of code that creates a new dictionary and populates it with the average values for each key in propNumDict.&amp;nbsp; Here's what that looks like:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;avgDailyDict &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;{&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;}&lt;/SPAN&gt;
&lt;SPAN class="keyword token"&gt;for&lt;/SPAN&gt; key&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; values &lt;SPAN class="keyword token"&gt;in&lt;/SPAN&gt; propNumDict&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;iteritems&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
    &lt;SPAN class="keyword token"&gt;if&lt;/SPAN&gt; float&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;len&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;values&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;&amp;gt;&lt;/SPAN&gt; &lt;SPAN class="number token"&gt;0&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
        avgDailyDict&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;key&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; sum&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;values&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="operator token"&gt;/&lt;/SPAN&gt;float&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;len&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;values&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;

&lt;SPAN class="keyword token"&gt;print&lt;/SPAN&gt; avgDailyDict&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;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;arc gis python‌&lt;/P&gt;&lt;P&gt;dictionary‌&lt;/P&gt;&lt;P&gt;arcpy.da.searchcursor‌&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 19:53:40 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-can-i-add-values-to-this-python-dictionary/m-p/445138#M34855</guid>
      <dc:creator>ChristopherBevilacqua</dc:creator>
      <dc:date>2021-12-11T19:53:40Z</dc:date>
    </item>
    <item>
      <title>Re: How can I add values to this  Python dictionary more efficiently?</title>
      <link>https://community.esri.com/t5/python-questions/how-can-i-add-values-to-this-python-dictionary/m-p/445139#M34856</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;you would have a small sample of what the data looks like would you?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 08 Feb 2019 22:07:59 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-can-i-add-values-to-this-python-dictionary/m-p/445139#M34856</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2019-02-08T22:07:59Z</dc:date>
    </item>
    <item>
      <title>Re: How can I add values to this  Python dictionary more efficiently?</title>
      <link>https://community.esri.com/t5/python-questions/how-can-i-add-values-to-this-python-dictionary/m-p/445140#M34857</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You are looping over the entire data set with the cursor for each &lt;SPAN style="font-family: courier new, courier, monospace;"&gt;prop&lt;/SPAN&gt;.&amp;nbsp; I am guessing it takes roughly 40 seconds to loop through the entire data and do no processing of the data.&amp;nbsp; There is a way to restructure the code to make it much more efficient, I just don't have the time at the moment to dive into it.&amp;nbsp; What you could try with little code refactoring is to add an SQL WHERE clause on the search cursor to limit the records being returned to only those of the &lt;SPAN style="font-family: courier new, courier, monospace;"&gt;prop&lt;/SPAN&gt; you are processing.&amp;nbsp; It is much faster for the back-end data store to filter records than pass all the records to the client and filter.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 08 Feb 2019 22:18:46 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-can-i-add-values-to-this-python-dictionary/m-p/445140#M34857</guid>
      <dc:creator>JoshuaBixby</dc:creator>
      <dc:date>2019-02-08T22:18:46Z</dc:date>
    </item>
    <item>
      <title>Re: How can I add values to this  Python dictionary more efficiently?</title>
      <link>https://community.esri.com/t5/python-questions/how-can-i-add-values-to-this-python-dictionary/m-p/445141#M34858</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Your loops are backwards.&amp;nbsp; The SearchCursor is always on the outer loop and you must do all lookups only on the dictionary in the inner loop.&amp;nbsp; This way you just go through the searchcursor rows once and don't get killed instatiating a new cursor for every value in your dictionary.&amp;nbsp; Also dictionaries are specifically designed to&amp;nbsp;optimize&amp;nbsp;the performance of lookup operations.&amp;nbsp; You should also apply a query to the SearchCursor to limit it to just records where the D_DATE &amp;gt; tMinus92.&amp;nbsp; The D_DATE field should be an indexed field to improve the performance of creating&amp;nbsp;a SearchCursor that&amp;nbsp;applies a query on that field.&amp;nbsp; I am not bothering to time one value, since now the entire table will be completed in seconds or minutes, depending on the size of the table.&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;table &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; acDaily &lt;SPAN class="comment token"&gt;# This is a SQL Server database table of daily water volumes.  There are ~1300 wells represented in the table, each with daily records covering several years.&lt;/SPAN&gt;
fields &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;'PROPNUM'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;'D_DATE'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;'WATER'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt; &lt;SPAN class="comment token"&gt;# PROPNUM is the unique identifier for each well in acDaily, D_DATE is the date of the daily volume, and WATER is the volume of produced water.&lt;/SPAN&gt;

&lt;SPAN class="keyword token"&gt;print&lt;/SPAN&gt; strftime&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"%Y-%m-%d %H:%M:%S"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;  &lt;SPAN class="comment token"&gt;# This is used to time the duration of the loop portion of the script.&lt;/SPAN&gt;

&lt;SPAN class="comment token"&gt;#Build an SQL expression to limit D_DATE to within the past 92 days&lt;/SPAN&gt;
SQL &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"D_DATE &amp;gt; '{}'"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;format&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;tMinus92&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;strftime&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;'%Y-%m-%d %H:%M:%S'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;

&lt;SPAN class="comment token"&gt;# Use a search cursor to go through the records that are from the past 92 days in acDaily and if the PROPNUM matches the key in propNumDict, add the water volume value to the dictionary.&lt;/SPAN&gt;
&lt;SPAN class="keyword token"&gt;with&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;da&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;SearchCursor&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;table&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; fields&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; SQL&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt; &lt;SPAN class="keyword token"&gt;as&lt;/SPAN&gt; cursor&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
&lt;SPAN class="keyword token"&gt;for&lt;/SPAN&gt; row &lt;SPAN class="keyword token"&gt;in&lt;/SPAN&gt; cursor&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
keyValue &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; row&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;0&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;
&lt;SPAN class="keyword token"&gt;if&lt;/SPAN&gt; keyValue &lt;SPAN class="keyword token"&gt;in&lt;/SPAN&gt; propNumDict&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
   &lt;SPAN class="comment token"&gt;# propNumDict was generated previously and start as an empty list prior to running the SearchCursor&lt;/SPAN&gt;
   propNumDict&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;keyValue&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;append&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;row&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;2&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;

&lt;SPAN class="keyword token"&gt;print&lt;/SPAN&gt; propNumDict
&lt;SPAN class="keyword token"&gt;print&lt;/SPAN&gt; strftime&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"%Y-%m-%d %H:%M:%S"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍&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;/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;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 19:53:43 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-can-i-add-values-to-this-python-dictionary/m-p/445141#M34858</guid>
      <dc:creator>RichardFairhurst</dc:creator>
      <dc:date>2021-12-11T19:53:43Z</dc:date>
    </item>
    <item>
      <title>Re: How can I add values to this  Python dictionary more efficiently?</title>
      <link>https://community.esri.com/t5/python-questions/how-can-i-add-values-to-this-python-dictionary/m-p/445142#M34859</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks for the feedback, Richard.&amp;nbsp; This looks so obvious now.&amp;nbsp; I had previously tried incorporating the date query as part of the search cursor, but hadn't been able to resolve SQL syntax errors.&amp;nbsp; I still have my loops reversed though.&lt;/P&gt;&lt;P&gt;I'll give your solution a try on Monday, hopefully, and will reply with results.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 08 Feb 2019 23:24:19 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-can-i-add-values-to-this-python-dictionary/m-p/445142#M34859</guid>
      <dc:creator>ChristopherBevilacqua</dc:creator>
      <dc:date>2019-02-08T23:24:19Z</dc:date>
    </item>
    <item>
      <title>Re: How can I add values to this  Python dictionary more efficiently?</title>
      <link>https://community.esri.com/t5/python-questions/how-can-i-add-values-to-this-python-dictionary/m-p/445143#M34860</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I reread your code and noticed your data source is coming from SQL Server.&amp;nbsp; So I modified&amp;nbsp;my code to change the original SQL expression which was using a date format that is compatible with file geodatabases to make it compatible with SQL Server by changing&lt;/P&gt;&lt;PRE class="" style="color: #000000; background: #f5f2f0; border: 0px; margin: 0.5em 0px; padding: 1em 1em 1em 3.8em;"&gt;&lt;CODE style="border: 0px; font-weight: inherit;"&gt;&lt;SPAN class="" style="color: #669900; border: 0px; font-weight: inherit;"&gt;SQL = "D_DATE &amp;gt; DATE '{}'"&lt;/SPAN&gt;&lt;SPAN class="" style="color: #999999; border: 0px; font-weight: inherit;"&gt;.&lt;/SPAN&gt;format&lt;SPAN class="" style="color: #999999; border: 0px; font-weight: inherit;"&gt;(&lt;/SPAN&gt;tMinus92&lt;SPAN class="" style="color: #999999; border: 0px; font-weight: inherit;"&gt;.&lt;/SPAN&gt;strftime&lt;SPAN class="" style="color: #999999; border: 0px; font-weight: inherit;"&gt;(&lt;/SPAN&gt;&lt;SPAN class="" style="color: #669900; border: 0px; font-weight: inherit;"&gt;'%Y-%m-%d %H:%M:%S'&lt;/SPAN&gt;&lt;SPAN class="" style="color: #999999; border: 0px; font-weight: inherit;"&gt;)&lt;/SPAN&gt;&lt;SPAN class="" style="color: #999999; border: 0px; font-weight: inherit;"&gt;)&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;to&lt;/P&gt;&lt;PRE class="" style="color: #000000; background: #f5f2f0; border: 0px; margin: 0.5em 0px; padding: 1em 1em 1em 3.8em;"&gt;&lt;CODE style="border: 0px; font-weight: inherit;"&gt;&lt;SPAN class="" style="color: #669900; border: 0px; font-weight: inherit;"&gt;SQL = "D_DATE &amp;gt; '{}'"&lt;/SPAN&gt;&lt;SPAN class="" style="color: #999999; border: 0px; font-weight: inherit;"&gt;.&lt;/SPAN&gt;format&lt;SPAN class="" style="color: #999999; border: 0px; font-weight: inherit;"&gt;(&lt;/SPAN&gt;tMinus92&lt;SPAN class="" style="color: #999999; border: 0px; font-weight: inherit;"&gt;.&lt;/SPAN&gt;strftime&lt;SPAN class="" style="color: #999999; border: 0px; font-weight: inherit;"&gt;(&lt;/SPAN&gt;&lt;SPAN class="" style="color: #669900; border: 0px; font-weight: inherit;"&gt;'%Y-%m-%d %H:%M:%S'&lt;/SPAN&gt;&lt;SPAN class="" style="color: #999999; border: 0px; font-weight: inherit;"&gt;)&lt;/SPAN&gt;&lt;SPAN class="" style="color: #999999; border: 0px; font-weight: inherit;"&gt;)&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 08 Feb 2019 23:42:14 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-can-i-add-values-to-this-python-dictionary/m-p/445143#M34860</guid>
      <dc:creator>RichardFairhurst</dc:creator>
      <dc:date>2019-02-08T23:42:14Z</dc:date>
    </item>
    <item>
      <title>Re: How can I add values to this  Python dictionary more efficiently?</title>
      <link>https://community.esri.com/t5/python-questions/how-can-i-add-values-to-this-python-dictionary/m-p/445144#M34861</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;IMG class="image-1 jive-image" src="https://community.esri.com/legacyfs/online/437055_pastedImage_1.png" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 11 Feb 2019 17:38:12 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-can-i-add-values-to-this-python-dictionary/m-p/445144#M34861</guid>
      <dc:creator>ChristopherBevilacqua</dc:creator>
      <dc:date>2019-02-11T17:38:12Z</dc:date>
    </item>
    <item>
      <title>Re: How can I add values to this  Python dictionary more efficiently?</title>
      <link>https://community.esri.com/t5/python-questions/how-can-i-add-values-to-this-python-dictionary/m-p/445145#M34862</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks again, Richard.&amp;nbsp; That works great.&amp;nbsp; The cursor runs through all the rows and populates the dictionary in about 4 seconds!&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 11 Feb 2019 17:39:29 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-can-i-add-values-to-this-python-dictionary/m-p/445145#M34862</guid>
      <dc:creator>ChristopherBevilacqua</dc:creator>
      <dc:date>2019-02-11T17:39:29Z</dc:date>
    </item>
  </channel>
</rss>

