<?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 Calculate Field in python? in Geoprocessing Questions</title>
    <link>https://community.esri.com/t5/geoprocessing-questions/using-calculate-field-in-python/m-p/251209#M8606</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Yes, but perhaps there is a case for some of these different methods of capitalizing the 1st letter in each word. I often find that many "out of the box" solutions don't do exactly what I want them to do. Just to be on the Devil's side...&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;gt;&amp;gt;&amp;gt; print "1234 can't st".title()&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;1234 Can'T Street&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Pretty much any grammatical contraction (like "can't") and even some colloquialism (like "ain't" and "y'all") would suffer at the hands of any algorithm that assumed the letter following an apostrophe should be capitalized. In addition, many place names in the U.S. often have non-English derivations for example: Coeur d'Alene, Idaho (Bad Example, But Y'All Get My Drift).&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 19 Jan 2011 14:49:58 GMT</pubDate>
    <dc:creator>ChrisSnyder</dc:creator>
    <dc:date>2011-01-19T14:49:58Z</dc:date>
    <item>
      <title>Using Calculate Field in python?</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/using-calculate-field-in-python/m-p/251189#M8586</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;The tool works well in the MODEL bilder, but when it wants to convert it to the python script error occurs. All data from the column disappear.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;import arcgisscripting&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;gp = arcgisscripting.create(9.3)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;gp.workspace = "D:\\DATA.gdb\\"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;TABLE = "D:\\DATA.gdb\\TABLE"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;FIELD = "texx"&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;gp.CalculateField_management("TABLE", "FIELD", "StrConv([texx],vbUpperCase)", "VB")&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;What am I doing wrong??&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 06 Jan 2011 16:18:35 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/using-calculate-field-in-python/m-p/251189#M8586</guid>
      <dc:creator>BartłomiejStaroń</dc:creator>
      <dc:date>2011-01-06T16:18:35Z</dc:date>
    </item>
    <item>
      <title>Re: Using Calculate Field in python?</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/using-calculate-field-in-python/m-p/251190#M8587</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Don't quote the first two params:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_macro_code jive_text_macro"&gt;gp.CalculateField_management(TABLE, FIELD, "StrConv([texx],vbUpperCase)", "VB")&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 06 Jan 2011 17:23:21 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/using-calculate-field-in-python/m-p/251190#M8587</guid>
      <dc:creator>JasonScheirer</dc:creator>
      <dc:date>2011-01-06T17:23:21Z</dc:date>
    </item>
    <item>
      <title>Re: Using Calculate Field in python?</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/using-calculate-field-in-python/m-p/251191#M8588</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Still not working:(&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;ExecuteError: ERROR 999999: Error executing function.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Type mismatch: 'StrConv'&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Failed to execute (CalculateField)&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 06 Jan 2011 17:50:39 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/using-calculate-field-in-python/m-p/251191#M8588</guid>
      <dc:creator>BartłomiejStaroń</dc:creator>
      <dc:date>2011-01-06T17:50:39Z</dc:date>
    </item>
    <item>
      <title>Re: Using Calculate Field in python?</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/using-calculate-field-in-python/m-p/251192#M8589</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Maybe I should use the cursor objects?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 07 Jan 2011 17:21:28 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/using-calculate-field-in-python/m-p/251192#M8589</guid>
      <dc:creator>BartłomiejStaroń</dc:creator>
      <dc:date>2011-01-07T17:21:28Z</dc:date>
    </item>
    <item>
      <title>Re: Using Calculate Field in python?</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/using-calculate-field-in-python/m-p/251193#M8590</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;How about trying it with Python, since it is a Python script?&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_macro_code jive_text_macro"&gt;gp.CalculateField_management(TABLE, "texx", "str(!texx!).upper()", "PYTHON", "")&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 07 Jan 2011 21:17:06 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/using-calculate-field-in-python/m-p/251193#M8590</guid>
      <dc:creator>JoeVondracek</dc:creator>
      <dc:date>2011-01-07T21:17:06Z</dc:date>
    </item>
    <item>
      <title>Re: Using Calculate Field in python?</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/using-calculate-field-in-python/m-p/251194#M8591</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I came up with something like this:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;cur = gp.UpdateCursor("sfora_2")&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;row = cur.Next()&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;while row:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; row.texx = str.capitalize(row.texx)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;print "end"&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;But it only replaces the first letter capitalized.&lt;/SPAN&gt;&lt;BR /&gt;&lt;STRONG style="text-decoration: underline;"&gt;I want to have every word that begins with a capital letter.&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;I have some ideas but I do not know how to implement it into the script.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;import re&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;w= "it should work"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;bbb = re.split('([ ] *)', w)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;''.join([each.capitalize() for each in bbb])&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;print ''.join([each.capitalize() for each in bbb])&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 12 Jan 2011 17:39:40 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/using-calculate-field-in-python/m-p/251194#M8591</guid>
      <dc:creator>BartłomiejStaroń</dc:creator>
      <dc:date>2011-01-12T17:39:40Z</dc:date>
    </item>
    <item>
      <title>Re: Using Calculate Field in python?</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/using-calculate-field-in-python/m-p/251195#M8592</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;It would look something like this:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;updateRows = gp.UpdateCursor("sfora_2")
updateRow = updateRows.Next()
while updateRow:
&amp;nbsp;&amp;nbsp; newString = ""
&amp;nbsp;&amp;nbsp; for word&amp;nbsp; in updateRow.MYFIELD.split(" "):
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; newString = item.capitalize() + " " + newString
&amp;nbsp;&amp;nbsp; updateRow.MYFIELD = newString[:-1]
updateRow = updateRows.Next()
del updateRow
del updateRows&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This code would take a field value of "hello world", and trun it into "Hello World".&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I think I am misunderstanding what you want to do though....&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If you have a string "hello world", what do you want it to look like?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If you want everything to be upper case (e.g. "HELLO WORLD"), do this:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;updateRows = gp.UpdateCursor("sfora_2")
updateRow = updateRows.Next()
while updateRow:
&amp;nbsp;&amp;nbsp; updateRow.MYFIELD = updateRow.MYFIELD.upper() #.upper() capitalizes every character
&amp;nbsp;&amp;nbsp; updateRow = updateRows.Next()
del updateRow
del updateRows&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 12:27:44 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/using-calculate-field-in-python/m-p/251195#M8592</guid>
      <dc:creator>ChrisSnyder</dc:creator>
      <dc:date>2021-12-11T12:27:44Z</dc:date>
    </item>
    <item>
      <title>Re: Using Calculate Field in python?</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/using-calculate-field-in-python/m-p/251196#M8593</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;The first script is what I was looking for.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;However, I will get an error:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;NameError: name 'item' is not defined&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Recently I started learning Python, so sorry to ask some simple questions.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 12 Jan 2011 19:56:55 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/using-calculate-field-in-python/m-p/251196#M8593</guid>
      <dc:creator>BartłomiejStaroń</dc:creator>
      <dc:date>2011-01-12T19:56:55Z</dc:date>
    </item>
    <item>
      <title>Re: Using Calculate Field in python?</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/using-calculate-field-in-python/m-p/251197#M8594</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Woops....&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;updateRows = gp.UpdateCursor("sfora_2")
updateRow = updateRows.Next()
while updateRow:
&amp;nbsp;&amp;nbsp; newString = ""
&amp;nbsp;&amp;nbsp; for word&amp;nbsp; in updateRow.MYFIELD.split(" "):
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; newString = word.capitalize() + " " + newString
&amp;nbsp;&amp;nbsp; updateRow.MYFIELD = newString[:-1]
updateRow = updateRows.Next()
del updateRow
del updateRows&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 12:27:47 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/using-calculate-field-in-python/m-p/251197#M8594</guid>
      <dc:creator>ChrisSnyder</dc:creator>
      <dc:date>2021-12-11T12:27:47Z</dc:date>
    </item>
    <item>
      <title>Re: Using Calculate Field in python?</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/using-calculate-field-in-python/m-p/251198#M8595</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I could have guessed.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks a lot.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I hope that the next script will not need much help.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 12 Jan 2011 20:39:37 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/using-calculate-field-in-python/m-p/251198#M8595</guid>
      <dc:creator>BartłomiejStaroń</dc:creator>
      <dc:date>2011-01-12T20:39:37Z</dc:date>
    </item>
    <item>
      <title>Re: Using Calculate Field in python?</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/using-calculate-field-in-python/m-p/251199#M8596</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Script awfully long does this operation. He made 10 hours and did nothing.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Maybe there is a logical error that does not allow the script to be finished?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 13 Jan 2011 07:24:19 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/using-calculate-field-in-python/m-p/251199#M8596</guid>
      <dc:creator>BartłomiejStaroń</dc:creator>
      <dc:date>2011-01-13T07:24:19Z</dc:date>
    </item>
    <item>
      <title>Re: Using Calculate Field in python?</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/using-calculate-field-in-python/m-p/251200#M8597</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;After more checking the script. The script ends without showing the error.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;However, nothing happens with the data.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 14 Jan 2011 18:17:35 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/using-calculate-field-in-python/m-p/251200#M8597</guid>
      <dc:creator>BartłomiejStaroń</dc:creator>
      <dc:date>2011-01-14T18:17:35Z</dc:date>
    </item>
    <item>
      <title>Re: Using Calculate Field in python?</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/using-calculate-field-in-python/m-p/251201#M8598</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;have you set the update script inside of a try/except block that passes off the messages from the geoprocessor i.e. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;try:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; .... your update script here...
except:
&amp;nbsp;&amp;nbsp;&amp;nbsp; print gp.Messages(2)
&amp;nbsp;&amp;nbsp;&amp;nbsp; gp.AddError(gp.Messages(2))&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The above code should alert you when something doesn't finish properly.&amp;nbsp; Otherwise there is a boilerplate error catch hosted someplace in the help topics for geoprocessing, I personally am phasing it out of all of my scripts in favor of "site specific" messaging on each piece of a script... &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I'm wrapping anything that starts with gp into a try block, OR creating a method that returns just that result.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;How many records are we talking about?&amp;nbsp; What kind of dataset are you connecting too?&amp;nbsp; I've seen issues where python thinks that the script is running successfully, but the server connection timed out and the dataset gets rolled back without update.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;good luck&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 12:27:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/using-calculate-field-in-python/m-p/251201#M8598</guid>
      <dc:creator>LukeBadgerow</dc:creator>
      <dc:date>2021-12-11T12:27:50Z</dc:date>
    </item>
    <item>
      <title>Re: Using Calculate Field in python?</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/using-calculate-field-in-python/m-p/251202#M8599</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Apologies - I often just write the code out in the forum post without running it! This "should" work:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;updateRows = gp.UpdateCursor("sfora_2")&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;updateRow = updateRows.Next()&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;while updateRow:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp; newString = ""&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp; for word&amp;nbsp; in updateRow.MYFIELD.split(" "):&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; newString = word.capitalize() + " " + newString&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp; updateRow.MYFIELD = newString[:-1]&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp; updateRows.updaterow(updateRow) #&amp;lt;&amp;lt;&amp;lt; THIS WAS THE MISSING LINE!&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;updateRow = updateRows.Next()&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;del updateRow&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;del updateRows&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 14 Jan 2011 19:04:55 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/using-calculate-field-in-python/m-p/251202#M8599</guid>
      <dc:creator>ChrisSnyder</dc:creator>
      <dc:date>2011-01-14T19:04:55Z</dc:date>
    </item>
    <item>
      <title>Re: Using Calculate Field in python?</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/using-calculate-field-in-python/m-p/251203#M8600</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Apologies - I often just write the code out in the forum post without running it! This "should" work:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;updateRows = gp.UpdateCursor("sfora_2")
updateRow = updateRows.Next()
while updateRow:
&amp;nbsp;&amp;nbsp; newString = ""
&amp;nbsp;&amp;nbsp; for word&amp;nbsp; in updateRow.MYFIELD.split(" "):
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; newString = word.capitalize() + " " + newString
&amp;nbsp;&amp;nbsp; updateRow.MYFIELD = newString[:-1]
&amp;nbsp;&amp;nbsp; updateRows.updaterow(updateRow) #&amp;lt;&amp;lt;&amp;lt; THIS WAS THE MISSING LINE!
updateRow = updateRows.Next()
del updateRow
del updateRows&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 12:27:52 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/using-calculate-field-in-python/m-p/251203#M8600</guid>
      <dc:creator>ChrisSnyder</dc:creator>
      <dc:date>2021-12-11T12:27:52Z</dc:date>
    </item>
    <item>
      <title>Re: Using Calculate Field in python?</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/using-calculate-field-in-python/m-p/251204#M8601</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Many thanks. The script works perfectly.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I just learn to write scripts. Still, not everything is so obvious to me:)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Now the script I will grow further.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 15 Jan 2011 05:14:22 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/using-calculate-field-in-python/m-p/251204#M8601</guid>
      <dc:creator>BartłomiejStaroń</dc:creator>
      <dc:date>2011-01-15T05:14:22Z</dc:date>
    </item>
    <item>
      <title>Re: Using Calculate Field in python?</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/using-calculate-field-in-python/m-p/251205#M8602</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Someone else just asked me the same thing. How about this one-liner?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;gp.CalculateField_management(fc,"name","string.capwords(!name!)","PYTHON","import string")&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;(You have to import the string module because it's not a built-in string function.)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;There may be other exceptions such as dashes and apostropies that need Uppercasing such as O'Brien or other Double-Banger names. In this case use a cursor and regular expression&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import arcgisscripting
import string
import re
gp = arcgisscripting.create(9.3)

# settings
fc = "d:/work/test.gdb/trail"
# simple way but inadequate
gp.CalculateField_management(fc,"name","string.capwords(!name!)","PYTHON","import string")
print gp.GetMessages()

# Handle imbedded quotes like O'Brien
quoteabbrev = re.compile("'[a-z]")
# just as fast as a calculate and we can trap exceptions, errors
cur = gp.UpdateCursor(fc)
row = cur.next()
while row:
&amp;nbsp;&amp;nbsp;&amp;nbsp; x = string.capwords(row.name)
&amp;nbsp;&amp;nbsp;&amp;nbsp; if quoteabbrev.search(x):
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print x,name
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; name = quoteabbrev.sub(quoteabbrev.search(x).group(0).upper(),x)
&amp;nbsp;&amp;nbsp;&amp;nbsp; cur.updateRow(row)
&amp;nbsp;&amp;nbsp;&amp;nbsp; row = cur.next()
del row,cur
print gp.GetMessages()&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I never got the VB equivalent ProperCase to work in a script.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 12:27:55 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/using-calculate-field-in-python/m-p/251205#M8602</guid>
      <dc:creator>KimOllivier</dc:creator>
      <dc:date>2021-12-11T12:27:55Z</dc:date>
    </item>
    <item>
      <title>Re: Using Calculate Field in python?</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/using-calculate-field-in-python/m-p/251206#M8603</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Someone else just asked me the same thing. How about this one-liner?&lt;BR /&gt;&lt;BR /&gt;gp.CalculateField_management(fc,"name","string.capwords(!name!)","PYTHON","import string")&lt;BR /&gt;&lt;BR /&gt;(You have to import the string module because it's not a built-in string function.)&lt;BR /&gt;&lt;BR /&gt;There may be other exceptions such as dashes and apostropies that need Uppercasing such as O'Brien or other Double-Banger names. In this case use a cursor and regular expression&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import arcgisscripting
import string
import re
gp = arcgisscripting.create(9.3)

# settings
fc = "d:/work/test.gdb/trail"
# simple way but inadequate
gp.CalculateField_management(fc,"name","string.capwords(!name!)","PYTHON","import string")
print gp.GetMessages()

# Handle imbedded quotes like O'Brien
quoteabbrev = re.compile("'[a-z]")
# just as fast as a calculate and we can trap exceptions, errors
cur = gp.UpdateCursor(fc)
row = cur.next()
while row:
&amp;nbsp;&amp;nbsp;&amp;nbsp; x = string.capwords(row.name)
&amp;nbsp;&amp;nbsp;&amp;nbsp; if quoteabbrev.search(x):
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print x,name
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; name = quoteabbrev.sub(quoteabbrev.search(x).group(0).upper(),x)
&amp;nbsp;&amp;nbsp;&amp;nbsp; cur.updateRow(row)
&amp;nbsp;&amp;nbsp;&amp;nbsp; row = cur.next()
del row,cur
print gp.GetMessages()&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;I never got the VB equivalent ProperCase to work in a script.&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I believe that the benevolent dictator for life is recommending that you not use the string module.&amp;nbsp; You can now use the string methods to accomplish most of what I believe you are trying to do, for instance&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;columnValue = "hello world" 

columnValue.split(" ")

returnValue = columnValue[0].capitalize() + " " columnValue[1].capitalize()
print returnValue

&amp;gt;&amp;gt;&amp;gt;"Hello World"&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Also it looks like you're trying to pass your entire coded returnvalue as a string:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;gp.CalculateField_management(fc,"name","string.cap words(!name!)","PYTHON","import string")&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Try it this way:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;returnValue = columnValue[0].capitalize() + " " columnValue[1].capitalize()
gp.CalculateField_management(fc, "field", returnValue, "PYTHON")&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;My only other recommendation would be to NOT let the geoprocessor interpret code for you you aside from SQL if you can help it.&amp;nbsp; Let the native python do as much of the work for you as possible.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 12:27:58 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/using-calculate-field-in-python/m-p/251206#M8603</guid>
      <dc:creator>LukeBadgerow</dc:creator>
      <dc:date>2021-12-11T12:27:58Z</dc:date>
    </item>
    <item>
      <title>Re: Using Calculate Field in python?</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/using-calculate-field-in-python/m-p/251207#M8604</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Seems there are many ways to skin this particular cat.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 18 Jan 2011 14:48:08 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/using-calculate-field-in-python/m-p/251207#M8604</guid>
      <dc:creator>ChrisSnyder</dc:creator>
      <dc:date>2011-01-18T14:48:08Z</dc:date>
    </item>
    <item>
      <title>Re: Using Calculate Field in python?</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/using-calculate-field-in-python/m-p/251208#M8605</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;@csny490&lt;/SPAN&gt;&lt;BR /&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;I believe that the benevolent dictator for life is recommending that you not use the string module. You can now use the string methods to accomplish most of what I believe you are trying to do, for instance&lt;BR /&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I could not find any reference or discussion in the PEP's suggesting the string module will be deprecated. I did see an uninformed speculation in the year 2000 at version 1.5 thinking that it may happen after string functions were built-in. It is still there in 3.0, stonger than ever with the new string Template functions.&lt;/SPAN&gt;&lt;BR /&gt;&lt;A href="http://docs.python.org/py3k/library/stdtypes.html#string-methods"&gt;http://docs.python.org/py3k/library/stdtypes.html#string-methods&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Since looking up the help I did find a better string function than string.capwords(&amp;lt;name&amp;gt;) called &amp;lt;name&amp;gt;.title() which does the same thing as capwords, but defines words as contiguous letters, so apostrophies and dashes are also counted as word boundaries (unlike capwords). This avoids using&amp;nbsp; regular expressions. The help does give an elegant example to handle special case exceptions using a generalised regular expression.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Therefore my one-liner can be even simpler and now handles name punctuation as is required for some strings such as roadnames. No need to import the string module even.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_macro_code jive_text_macro"&gt;gp.CalculateField_management(fc,"name","!name!.title()","PYTHON")&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Note that I do not have to handle variable numbers of words in the string, and there is no need to define a function in a block.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;At Version 10 you can use Python expressions in the interactive field calculator to replace VB expressions so this would be very easy.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;You will have to expand your comments regarding&amp;nbsp; returning entire strings, I don't want the strings returned and they are not, they are written directly into the featureclass if you use CalculateField.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;"Letting the geoprocessor interpret code"? I have no idea what you are getting at.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 19 Jan 2011 08:46:02 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/using-calculate-field-in-python/m-p/251208#M8605</guid>
      <dc:creator>KimOllivier</dc:creator>
      <dc:date>2011-01-19T08:46:02Z</dc:date>
    </item>
  </channel>
</rss>

