<?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: ArcPy Update Cursor if/else in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/arcpy-update-cursor-if-else/m-p/493945#M38762</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Joe:&lt;/P&gt;&lt;P&gt;&amp;nbsp; Thank you for the links. That is a cool script. However, I can I use this within a feature class/table? I have a field (READING_DATE) Date type and (BILLING_DATE) Text type. Example here:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;IMG class="image-1 jive-image" src="https://community.esri.com/legacyfs/online/450860_pastedImage_1.png" /&gt;&lt;/P&gt;&lt;P&gt;I want to run a script that will take the reading date (date type) and convert it to the billing date (text type) and write/update the billing date field.&amp;nbsp;&lt;/P&gt;&lt;P&gt;The tool I use now Convert Time Field (Data Management) takes 5 to 6 hours to do this process.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 19 Jun 2019 18:59:03 GMT</pubDate>
    <dc:creator>ModernElectric</dc:creator>
    <dc:date>2019-06-19T18:59:03Z</dc:date>
    <item>
      <title>ArcPy Update Cursor if/else</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-update-cursor-if-else/m-p/493933#M38750</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Good Afternoon:&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;I have been doing multiple searches on how to correctly write an if/else statement using Update Cursor to update a specific field based on the criteria in a different field, and lets say I got nothing.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; Looking for a little help on how to write this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;I have a field called BILLING_MONTH_TEXT (text) and another field called BILLING_DATE (text).&lt;/P&gt;&lt;P&gt;What I need to do is say (As an Example) if BILLING_MONTH_TEXT is May-2019 then it would update BILLING_DATE with a value of 30. If it is April-2019, the value would be 29. And so on and so on.&amp;nbsp;&lt;/P&gt;&lt;P&gt;If I could get started, I can figure out how to fill in the remaining months and values.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank You for your help.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 18 Jun 2019 22:27:58 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-update-cursor-if-else/m-p/493933#M38750</guid>
      <dc:creator>ModernElectric</dc:creator>
      <dc:date>2019-06-18T22:27:58Z</dc:date>
    </item>
    <item>
      <title>Re: ArcPy Update Cursor if/else</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-update-cursor-if-else/m-p/493934#M38751</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Rather than an if elif else block, you&amp;nbsp;might want to take a look at&amp;nbsp;&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" target="_blank"&gt;https://community.esri.com/blogs/richard_fairhurst/2014/11/08/turbo-charging-data-manipulation-with-python-cursors-and-dictionaries&lt;/A&gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I've used Richard's approach more than once and it's pretty slick.&amp;nbsp; In your case, you would make a dictionary of Month/Number pairs of keys and values like this:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;monthDict &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;{&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;'April'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;29&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;'May'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;30&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;'Month'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;Number&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;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;and your update cursor might look something like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;target = 'your feature class'
updateFields = ‍‍['BILLING_MONTH_TEXT', 'BILLING_DATE']

with arcpy.da.UpdateCursor(target,updateFields) as updateRows:
    for updateRow in updateRows:
        keyValue = updateRow[0]
        if keyValue in monthDict:
           updateRow[1] = monthDict[keyValue][0]
           updateRows.updateRow(updateRow)‍‍‍‍‍‍‍‍&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;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Untested...&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 21:44:08 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-update-cursor-if-else/m-p/493934#M38751</guid>
      <dc:creator>JoeBorgione</dc:creator>
      <dc:date>2021-12-11T21:44:08Z</dc:date>
    </item>
    <item>
      <title>Re: ArcPy Update Cursor if/else</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-update-cursor-if-else/m-p/493935#M38752</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Joe:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;Thank you for taking a look and providing me with additional information to look at. I build the script example you sent me. However, I am getting this error:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;updateRow[1] = monthDict[keyValue][0]&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;TypeError: 'int' object has no attribute '__getitem__'&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any advice?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 19 Jun 2019 14:24:39 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-update-cursor-if-else/m-p/493935#M38752</guid>
      <dc:creator>ModernElectric</dc:creator>
      <dc:date>2019-06-19T14:24:39Z</dc:date>
    </item>
    <item>
      <title>Re: ArcPy Update Cursor if/else</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-update-cursor-if-else/m-p/493936#M38753</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Taking a step back, are you looking to set the billing date on the second to last day of each month?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 19 Jun 2019 14:46:55 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-update-cursor-if-else/m-p/493936#M38753</guid>
      <dc:creator>JoshuaBixby</dc:creator>
      <dc:date>2019-06-19T14:46:55Z</dc:date>
    </item>
    <item>
      <title>Re: ArcPy Update Cursor if/else</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-update-cursor-if-else/m-p/493937#M38754</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;As mentioned, untested, but....&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;dateDict &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;{&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;'April'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;29&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;'May'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;31&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;}&lt;/SPAN&gt;
keyValue &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;'April'&lt;/SPAN&gt;
&lt;SPAN class="keyword token"&gt;if&lt;/SPAN&gt; keyValue &lt;SPAN class="keyword token"&gt;in&lt;/SPAN&gt; dateDict&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
    &lt;SPAN class="keyword token"&gt;print&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;dateDict&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;get&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;&lt;SPAN class="number token"&gt;0&lt;/SPAN&gt;&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="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;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Just worked for me,&amp;nbsp;returning 29. See if this revised code works for you:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&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;UpdateCursor&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;target&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;updateFields&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt; &lt;SPAN class="keyword token"&gt;as&lt;/SPAN&gt; updateRows&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
    &lt;SPAN class="keyword token"&gt;for&lt;/SPAN&gt; updateRow &lt;SPAN class="keyword token"&gt;in&lt;/SPAN&gt; updateRows&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
        keyValue &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; updateRow&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; monthDict&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
           updateRow&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;=&lt;/SPAN&gt; monthDict&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;get&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;&lt;SPAN class="number token"&gt;0&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
           updateRows&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;updateRow&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;updateRow&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;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Got the idea from:&amp;nbsp;&amp;nbsp;&lt;A href="https://www.tutorialspoint.com/python/dictionary_get.htm" rel="nofollow noopener noreferrer" target="_blank"&gt;https://www.tutorialspoint.com/python/dictionary_get.htm&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 21:44:11 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-update-cursor-if-else/m-p/493937#M38754</guid>
      <dc:creator>JoeBorgione</dc:creator>
      <dc:date>2021-12-11T21:44:11Z</dc:date>
    </item>
    <item>
      <title>Re: ArcPy Update Cursor if/else</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-update-cursor-if-else/m-p/493938#M38755</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I think I am being a little vague on what I am trying to do. I have a table of reading data (approx 15,000 records) of approx 30 months. I have one field that is the billing date (ex. May-2019). The other field is the billing month (ex. 30). Basically, I started with Dec-2016 which has a value of 1, Jan-2017 which is assigned a value of 2 and so on and so forth to May-2019. A previous step uses the Convert Date tool to get the May-2019. This step is to update the Billing Month field based on the value in the Billing Date field.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hope this helps and makes more sense.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 19 Jun 2019 14:55:09 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-update-cursor-if-else/m-p/493938#M38755</guid>
      <dc:creator>ModernElectric</dc:creator>
      <dc:date>2019-06-19T14:55:09Z</dc:date>
    </item>
    <item>
      <title>Re: ArcPy Update Cursor if/else</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-update-cursor-if-else/m-p/493939#M38756</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;So effectively your final data would look something like:&lt;/P&gt;&lt;TABLE class="j-table jiveBorder" style="border: 1px solid #c6c6c6; width: 75.0627%;"&gt;&lt;THEAD&gt;&lt;TR style="background-color: #efefef;"&gt;&lt;TH style="width: 44.7368%;"&gt;BILL_DATE&lt;/TH&gt;&lt;TH style="width: 27.4436%;"&gt;BILL_MONTH&lt;/TH&gt;&lt;/TR&gt;&lt;/THEAD&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD style="width: 44.7368%;"&gt;Dec-2016&lt;/TD&gt;&lt;TD style="width: 27.4436%;"&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="width: 44.7368%;"&gt;Dec-2016&lt;/TD&gt;&lt;TD style="width: 27.4436%;"&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="width: 44.7368%;"&gt;Jan-2017&lt;/TD&gt;&lt;TD style="width: 27.4436%;"&gt;&lt;P&gt;2&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="width: 44.7368%;"&gt;...&lt;/TD&gt;&lt;TD style="width: 27.4436%;"&gt;...&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="width: 44.7368%;"&gt;June-2018&lt;/TD&gt;&lt;TD style="width: 27.4436%;"&gt;19&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="width: 44.7368%;"&gt;...&lt;/TD&gt;&lt;TD style="width: 27.4436%;"&gt;...&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="width: 44.7368%;"&gt;June-2018&lt;/TD&gt;&lt;TD style="width: 27.4436%;"&gt;19&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="width: 44.7368%;"&gt;July-2018&lt;/TD&gt;&lt;TD style="width: 27.4436%;"&gt;20&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="width: 44.7368%;"&gt;...&lt;/TD&gt;&lt;TD style="width: 27.4436%;"&gt;...&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="width: 44.7368%;"&gt;May-2019&lt;/TD&gt;&lt;TD style="width: 27.4436%;"&gt;30&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 19 Jun 2019 15:08:00 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-update-cursor-if-else/m-p/493939#M38756</guid>
      <dc:creator>JoshuaBixby</dc:creator>
      <dc:date>2019-06-19T15:08:00Z</dc:date>
    </item>
    <item>
      <title>Re: ArcPy Update Cursor if/else</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-update-cursor-if-else/m-p/493940#M38757</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Joshua:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;Yes, in a nut shell that would be correct.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a series of Model(s) in ArcToolBox that runs my process for me (Billing Data) and it takes&amp;nbsp;several hours to run the process. I am working on transitioning the model(s) to python scripts to make the process run faster and maybe run it automatically through a series of batch file(s).&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 19 Jun 2019 15:13:40 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-update-cursor-if-else/m-p/493940#M38757</guid>
      <dc:creator>ModernElectric</dc:creator>
      <dc:date>2019-06-19T15:13:40Z</dc:date>
    </item>
    <item>
      <title>Re: ArcPy Update Cursor if/else</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-update-cursor-if-else/m-p/493941#M38758</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank You Joe. That worked. I checked the table in ArcCatalog after running the script and the field I needed updating in-fact had the series of 29(s) and 30(s) updated.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Going to spend some time learning more about Dictionaries and Update Cursor from the information you attached to this post.&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 19 Jun 2019 15:16:30 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-update-cursor-if-else/m-p/493941#M38758</guid>
      <dc:creator>ModernElectric</dc:creator>
      <dc:date>2019-06-19T15:16:30Z</dc:date>
    </item>
    <item>
      <title>Re: ArcPy Update Cursor if/else</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-update-cursor-if-else/m-p/493942#M38759</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Dictionaries are cool; they take a moment to get your head wrapped around them, but they are worth the effort.&amp;nbsp; Same goes for update cursors.&amp;nbsp; This forum is where I learned about both, with&amp;nbsp;a ton&amp;nbsp;of guidance from&amp;nbsp;&lt;A href="https://community.esri.com/migrated-users/3420"&gt;Joshua Bixby&lt;/A&gt;‌&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 19 Jun 2019 15:24:34 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-update-cursor-if-else/m-p/493942#M38759</guid>
      <dc:creator>JoeBorgione</dc:creator>
      <dc:date>2019-06-19T15:24:34Z</dc:date>
    </item>
    <item>
      <title>Re: ArcPy Update Cursor if/else</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-update-cursor-if-else/m-p/493943#M38760</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Joe:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;You been a huge help and I appreciate it. Wanted to see if you could help me on one more thing. One of the process is to take a field called READING_DATE (Date field type) in a m/d/y format and convert it to a field BILLING_DATE (Text field type) in a format of m-y (May-2019). I am currently using the CONVERT_TIME tool in a data model and with almost 15,000 rows it takes almost 5 hours to complete. I want to be able to use a cursor to see if this will drastically decrease the amount of time it takes to convert the field.&lt;/P&gt;&lt;P&gt;Thanks Again&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 19 Jun 2019 17:21:24 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-update-cursor-if-else/m-p/493943#M38760</guid>
      <dc:creator>ModernElectric</dc:creator>
      <dc:date>2019-06-19T17:21:24Z</dc:date>
    </item>
    <item>
      <title>Re: ArcPy Update Cursor if/else</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-update-cursor-if-else/m-p/493944#M38761</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Ooooo. Everyone's favorite; date fields....&amp;nbsp; I'm not familiar with&amp;nbsp;&lt;SPAN style="background-color: #ffffff;"&gt;the CONVERT_TIME tool&lt;/SPAN&gt; &amp;nbsp;you mention, but python has the datetime module and when you import it, you get the strftime() method and that guy is your friend. Check this out:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;&lt;SPAN class="keyword token"&gt;import&lt;/SPAN&gt; datetime

today &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; datetime&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;datetime&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;now&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
Today1 &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; today&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;'%m-%d-%y'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
Today2 &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; today&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;'%m %d %y'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
Today3 &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; today&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;'%B-%Y'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;


&lt;SPAN class="keyword token"&gt;print&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;Today1&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
&lt;SPAN class="keyword token"&gt;print&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;Today2&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
&lt;SPAN class="keyword token"&gt;print&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;Today3&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;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Copy that and and run it in a python window of your choice.&amp;nbsp; Afterwards, check out:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="https://docs.python.org/2/library/datetime.html" rel="nofollow noopener noreferrer" target="_blank"&gt;https://docs.python.org/2/library/datetime.html&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="https://www.w3schools.com/python/python_datetime.asp" rel="nofollow noopener noreferrer" target="_blank"&gt;https://www.w3schools.com/python/python_datetime.asp&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;these are bookmark-worthy....&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 21:44:14 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-update-cursor-if-else/m-p/493944#M38761</guid>
      <dc:creator>JoeBorgione</dc:creator>
      <dc:date>2021-12-11T21:44:14Z</dc:date>
    </item>
    <item>
      <title>Re: ArcPy Update Cursor if/else</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-update-cursor-if-else/m-p/493945#M38762</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Joe:&lt;/P&gt;&lt;P&gt;&amp;nbsp; Thank you for the links. That is a cool script. However, I can I use this within a feature class/table? I have a field (READING_DATE) Date type and (BILLING_DATE) Text type. Example here:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;IMG class="image-1 jive-image" src="https://community.esri.com/legacyfs/online/450860_pastedImage_1.png" /&gt;&lt;/P&gt;&lt;P&gt;I want to run a script that will take the reading date (date type) and convert it to the billing date (text type) and write/update the billing date field.&amp;nbsp;&lt;/P&gt;&lt;P&gt;The tool I use now Convert Time Field (Data Management) takes 5 to 6 hours to do this process.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 19 Jun 2019 18:59:03 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-update-cursor-if-else/m-p/493945#M38762</guid>
      <dc:creator>ModernElectric</dc:creator>
      <dc:date>2019-06-19T18:59:03Z</dc:date>
    </item>
    <item>
      <title>Re: ArcPy Update Cursor if/else</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-update-cursor-if-else/m-p/493946#M38763</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;The tool I use now Convert Time Field (Data Management) takes 5 to 6 hours to do this process.&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;The Convert Time Field tool should be able to process millions of records in minutes.&amp;nbsp; Something is definitely off if it is taking that long for the number of records you have involved.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I agree with Joe that dictionaries are cool.&amp;nbsp; Beyond being cool, they are at the core of so much of the Python language.&amp;nbsp; All that said, I don't really see dictionaries as being well suited to your situation.&amp;nbsp; Your situation isn't really if/else, it is more group by and increment.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regarding your question of converting READING_DATE to BILLING_DATE, the answer partially depends on whether you are using ArcMap or ArcGIS Pro.&amp;nbsp; How dates are returned from cursors and the field calculator varies between the two products.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;After you having BILLING_DATE populated, the following code (adopted from&amp;nbsp;&lt;A _jive_internal="true" class="link-titled" href="https://community.esri.com/thread/216866-sort-field-and-then-calculate-sequential-values?commentID=813573#comment" title="https://community.esri.com/message/813573-re-sort-field-and-then-calculate-sequential-values?commentID=813573#comment-813573" target="_blank"&gt;Sort Field and then Calculate Sequential Values&lt;/A&gt; ) will give you the results using an approach that I think is more suited to your data.&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;&lt;SPAN class="keyword token"&gt;import&lt;/SPAN&gt; arcpy
&lt;SPAN class="keyword token"&gt;from&lt;/SPAN&gt; itertools &lt;SPAN class="keyword token"&gt;import&lt;/SPAN&gt; count&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; groupby
&lt;SPAN class="keyword token"&gt;from&lt;/SPAN&gt; operator &lt;SPAN class="keyword token"&gt;import&lt;/SPAN&gt; itemgetter

tbl &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="comment token"&gt;# path to table/feature class or name of table view/feature layer&lt;/SPAN&gt;
case_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;"BILLING_DATE"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;
increment_field &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"BILLING_MONTH"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;
sql_orderby &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"ORDER BY {}"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;format&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;", "&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;join&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;case_fields&lt;SPAN class="punctuation token"&gt;)&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;UpdateCursor&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;
   tbl&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;
   case_fields &lt;SPAN class="operator token"&gt;+&lt;/SPAN&gt; increment_field&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;
   sql_clause&lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;None&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; sql_orderby&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
&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;
    counter &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; count&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
    case_func &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; itemgetter&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="operator token"&gt;*&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;cursor&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;fields&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;index&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;fld&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt; &lt;SPAN class="keyword token"&gt;for&lt;/SPAN&gt; fld &lt;SPAN class="keyword token"&gt;in&lt;/SPAN&gt; case_fields&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; group &lt;SPAN class="keyword token"&gt;in&lt;/SPAN&gt; groupby&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;cursor&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; case_func&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
        key &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; key &lt;SPAN class="keyword token"&gt;if&lt;/SPAN&gt; isinstance&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;key&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; tuple&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt; &lt;SPAN class="keyword token"&gt;else&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;key&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
        c &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; next&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;counter&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt; &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;for&lt;/SPAN&gt; row &lt;SPAN class="keyword token"&gt;in&lt;/SPAN&gt; group&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
              cursor&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;updateRow&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;list&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; &lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;c&lt;SPAN class="punctuation token"&gt;]&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;/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 21:44:16 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-update-cursor-if-else/m-p/493946#M38763</guid>
      <dc:creator>JoshuaBixby</dc:creator>
      <dc:date>2021-12-11T21:44:16Z</dc:date>
    </item>
    <item>
      <title>Re: ArcPy Update Cursor if/else</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-update-cursor-if-else/m-p/493947#M38764</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;That's just a concept script; you'd need to take those elements and add them into an update cursor.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 19 Jun 2019 19:54:02 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-update-cursor-if-else/m-p/493947#M38764</guid>
      <dc:creator>JoeBorgione</dc:creator>
      <dc:date>2019-06-19T19:54:02Z</dc:date>
    </item>
    <item>
      <title>Re: ArcPy Update Cursor if/else</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-update-cursor-if-else/m-p/493948#M38765</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The Convert Time Field tool is being used with a number of other tool(s) in a stand-alone python script that will later be combined into a batch file for easier processing.&amp;nbsp;&lt;/P&gt;&lt;P&gt;The code that I am using to convert the raw READING_DATE field to the text file is this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;arcpy.ConvertTimeField_management(ELECTRIC_METER_READING_RAWDATA, "READING_DATE", "'Not Used'", "READING_DATE_CONVERT_TEXT", "TEXT", "MM/dd/yyyy;1033;;")&lt;/P&gt;&lt;P&gt;Last time I tried to run it with only about 8,000 rows, it took about 25 minutes to run.&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is what it looks like when its finally done:&lt;/P&gt;&lt;P&gt;&lt;IMG class="image-1 jive-image" src="https://community.esri.com/legacyfs/online/450861_pastedImage_1.png" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 19 Jun 2019 19:55:33 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-update-cursor-if-else/m-p/493948#M38765</guid>
      <dc:creator>ModernElectric</dc:creator>
      <dc:date>2019-06-19T19:55:33Z</dc:date>
    </item>
  </channel>
</rss>

