<?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: Split text field into two new fields? in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/split-text-field-into-two-new-fields/m-p/553417#M43201</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;You'll want to use AddField to add the new field for splitting, then use two CalculateValue calls -- one to populate the new field and another to truncate down the old field into the first word.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 24 Nov 2010 17:22:03 GMT</pubDate>
    <dc:creator>JasonScheirer</dc:creator>
    <dc:date>2010-11-24T17:22:03Z</dc:date>
    <item>
      <title>Split text field into two new fields?</title>
      <link>https://community.esri.com/t5/python-questions/split-text-field-into-two-new-fields/m-p/553416#M43200</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I'm a GIS MA student looking for some help on creating a Python script in ArcGIS for a class project. I have a text table with several fields (Tenant Name; Address; Sq Ft; Destination). The destination column contains information that I want to separate into two new fields - one for the first word in the original column and one for the second word in the original column. I then need to write this new info back into the original table.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;What ArcPy commands should I be looking at to accomplish this? Can anyone point me to a similar finished script?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;David&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 24 Nov 2010 16:51:40 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/split-text-field-into-two-new-fields/m-p/553416#M43200</guid>
      <dc:creator>DavidMedeiros</dc:creator>
      <dc:date>2010-11-24T16:51:40Z</dc:date>
    </item>
    <item>
      <title>Re: Split text field into two new fields?</title>
      <link>https://community.esri.com/t5/python-questions/split-text-field-into-two-new-fields/m-p/553417#M43201</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;You'll want to use AddField to add the new field for splitting, then use two CalculateValue calls -- one to populate the new field and another to truncate down the old field into the first word.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 24 Nov 2010 17:22:03 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/split-text-field-into-two-new-fields/m-p/553417#M43201</guid>
      <dc:creator>JasonScheirer</dc:creator>
      <dc:date>2010-11-24T17:22:03Z</dc:date>
    </item>
    <item>
      <title>Re: Split text field into two new fields?</title>
      <link>https://community.esri.com/t5/python-questions/split-text-field-into-two-new-fields/m-p/553418#M43202</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;If you want:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;ORIG_FIELD = "My House"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;SPLIT1 = "My"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;SPLIT2 = "House"&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The Python syntax for the Calculate Field tool would be:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;SPLIT1 = !ORIG_FIELD!.split(" ")[0] #0 being the 1st word&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;SPLIT1 = !ORIG_FIELD!.split(" ")[-1] #-1 being the last word&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 24 Nov 2010 17:51:06 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/split-text-field-into-two-new-fields/m-p/553418#M43202</guid>
      <dc:creator>ChrisSnyder</dc:creator>
      <dc:date>2010-11-24T17:51:06Z</dc:date>
    </item>
    <item>
      <title>Re: Split text field into two new fields?</title>
      <link>https://community.esri.com/t5/python-questions/split-text-field-into-two-new-fields/m-p/553419#M43203</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;If you have records with multiple spaces this will fall down. There's an optional second argument to string.split to limit the number of splits performed:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;SPLIT1 = !ORIG_FIELD!.split(" ", 1)[0] #0 being the 1st word&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;SPLIT2 = !ORIG_FIELD!.split(" ", 1)[-1] #-1 being the last word&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;And then you may only have one token, in which case you can use a conditional variable to rightly leave the second field as blank (otherwise, [0] and [-1] will be pointing to the same index in the list, meaning both fields are populated with the same value). So a more refined version would be:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;SPLIT1 = !ORIG_FIELD!.split(" ", 1)[0]&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;SPLIT2 = !ORIG_FIELD!.split(" ", 1)[1] if " " in !ORIG_FIELD! else ""&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 24 Nov 2010 18:26:34 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/split-text-field-into-two-new-fields/m-p/553419#M43203</guid>
      <dc:creator>JasonScheirer</dc:creator>
      <dc:date>2010-11-24T18:26:34Z</dc:date>
    </item>
    <item>
      <title>Re: Split text field into two new fields?</title>
      <link>https://community.esri.com/t5/python-questions/split-text-field-into-two-new-fields/m-p/553420#M43204</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I should probably have waited to post this question until after the holiday so I could be trying this out in the lab, but this looks like it will be a great help, thank you!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;All records in that field have single space, but some do only have one entry instead of two.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 24 Nov 2010 18:45:40 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/split-text-field-into-two-new-fields/m-p/553420#M43204</guid>
      <dc:creator>DavidMedeiros</dc:creator>
      <dc:date>2010-11-24T18:45:40Z</dc:date>
    </item>
    <item>
      <title>Re: Split text field into two new fields?</title>
      <link>https://community.esri.com/t5/python-questions/split-text-field-into-two-new-fields/m-p/553421#M43205</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Alright here's where I've gotten to on this:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;[INDENT]# split table script&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;#add field step (keep)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;import arcpy&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;from arcpy import env&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;inputTable = arcpy.GetParameterAsText(0)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;inputField = arcpy.GetParameterAsText(1)&amp;nbsp; #"Dest" column, set in toolbox properties&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;#list fields (stops duplicate add fields)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;theFieldList = arcpy.ListFields (inputTable, "Type")&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.AddMessage ("the count" + str(len(theFieldList)))&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;#following exectues the add field (keep)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;if len(theFieldList) == 0:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddField_management(inputTable, "Type", "TEXT")&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;else:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddMessage ("Field Exists")&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;#split field loop&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;theItemList = arcpy.SearchCursor (inputTable)&amp;nbsp; #gets all vlaues for table&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;for thisItem in theItemList:&amp;nbsp; #loops through vlaues&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; thisValue = thisItem.getValue (inputField)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; split = !thisValue!.split(" ",1)[-1] if " " in !thisValue! else ""&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; setValue...[/INDENT]&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The add field portion works, I'm not sure if I'm going in the right direction with the loop above and I don't know what the syntax is to set the value back into my new field. Does this look correct (aside from being incomplete)?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 01 Dec 2010 17:24:17 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/split-text-field-into-two-new-fields/m-p/553421#M43205</guid>
      <dc:creator>DavidMedeiros</dc:creator>
      <dc:date>2010-12-01T17:24:17Z</dc:date>
    </item>
    <item>
      <title>Re: Split text field into two new fields?</title>
      <link>https://community.esri.com/t5/python-questions/split-text-field-into-two-new-fields/m-p/553422#M43206</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;If you want to write new data to the table you would need to use an update cursor (not a search cursor). Also, you have to use cursor syntax, not field calculator syntax.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 01 Dec 2010 17:52:17 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/split-text-field-into-two-new-fields/m-p/553422#M43206</guid>
      <dc:creator>ChrisSnyder</dc:creator>
      <dc:date>2010-12-01T17:52:17Z</dc:date>
    </item>
    <item>
      <title>Re: Split text field into two new fields?</title>
      <link>https://community.esri.com/t5/python-questions/split-text-field-into-two-new-fields/m-p/553423#M43207</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;If you want to write new data to the table you would need to use an update cursor (not a search cursor). Also, you have to use cursor syntax, not field calculator syntax.&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;So I would drop the calculate field "split" command? Or use it together with the update cursor?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;What I have so far is a new field, into which I want to place the second value from another filed (forget about truncating first field, not needed).&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 07 Dec 2010 23:18:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/split-text-field-into-two-new-fields/m-p/553423#M43207</guid>
      <dc:creator>DavidMedeiros</dc:creator>
      <dc:date>2010-12-07T23:18:50Z</dc:date>
    </item>
    <item>
      <title>Re: Split text field into two new fields?</title>
      <link>https://community.esri.com/t5/python-questions/split-text-field-into-two-new-fields/m-p/553424#M43208</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Ok, I'm successfully updating the row - bigger achievement for me than you might think! &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt; But, I'm only getting the last character instead of the second word from the original row. Here's my script:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;# split table script&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;#add field step (keep)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;import arcpy&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;from arcpy import env&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;inputTable = arcpy.GetParameterAsText(0)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.AddMessage ("input " + inputTable)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;#list fields (stops duplicate add fields)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;theFieldList = arcpy.ListFields (inputTable, "Type")&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.AddMessage ("the count" + str(len(theFieldList)))&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;#following exectues the add field (keep)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;if len(theFieldList) == 0:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddField_management(inputTable, "Type", "TEXT")&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;else:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddMessage ("Field Exists")&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;#split field loop&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;rows = arcpy.UpdateCursor (inputTable)&amp;nbsp; #gets all vlaues for table&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;for row in rows:&amp;nbsp; #loops through vlaues&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; row.Type = row.Dest[-1] &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; rows.updateRow(row)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;del row&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;del rows&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I know I need to change the modifier on the row.Dest[-1] syntax but I thought the [-1] gave me the second word?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 07 Dec 2010 23:43:31 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/split-text-field-into-two-new-fields/m-p/553424#M43208</guid>
      <dc:creator>DavidMedeiros</dc:creator>
      <dc:date>2010-12-07T23:43:31Z</dc:date>
    </item>
    <item>
      <title>Re: Split text field into two new fields?</title>
      <link>https://community.esri.com/t5/python-questions/split-text-field-into-two-new-fields/m-p/553425#M43209</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;No, -1 gives you the last value (which may coincidentally be the 2nd item if there are only two items). For example:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;list = ["a","b","c","d"]&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;list[0] = "a"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;list[1] = "b"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;list[2] = "c"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;list[3] = "d"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;list[4] = ERROR! Index out of range...&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;list[-1] = "d"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;list[-2] = "c"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;list[-3] = "b"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;list[-4] = "a"&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;list[0:2] = ["a","b"]&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 07 Dec 2010 23:51:46 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/split-text-field-into-two-new-fields/m-p/553425#M43209</guid>
      <dc:creator>ChrisSnyder</dc:creator>
      <dc:date>2010-12-07T23:51:46Z</dc:date>
    </item>
    <item>
      <title>Re: Split text field into two new fields?</title>
      <link>https://community.esri.com/t5/python-questions/split-text-field-into-two-new-fields/m-p/553426#M43210</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Ahh, I mistook last value for last whole word. Is there a modifier to the &lt;/SPAN&gt;&lt;SPAN style="font-style:italic;"&gt;row.Type = row.Dest&lt;/SPAN&gt;&lt;SPAN&gt; statement that can select the entire last word from the original row?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 08 Dec 2010 00:01:17 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/split-text-field-into-two-new-fields/m-p/553426#M43210</guid>
      <dc:creator>DavidMedeiros</dc:creator>
      <dc:date>2010-12-08T00:01:17Z</dc:date>
    </item>
    <item>
      <title>Re: Split text field into two new fields?</title>
      <link>https://community.esri.com/t5/python-questions/split-text-field-into-two-new-fields/m-p/553427#M43211</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Ok, I think I got it. Here's the script:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Script:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;# split table script&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;#add field step &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;import arcpy&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;from arcpy import env&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;inputTable = arcpy.GetParameterAsText(0)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.AddMessage ("input " + inputTable)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;#list fields (stops duplicate add fields)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;theFieldList = arcpy.ListFields (inputTable, "Type")&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.AddMessage ("the count" + str(len(theFieldList)))&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;#following exectues the add field&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;if len(theFieldList) == 0:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddField_management(inputTable, "Type", "TEXT")&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;else:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddMessage ("Field Exists")&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;#split field loop&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;rows = arcpy.UpdateCursor (inputTable)&amp;nbsp; #gets all vlaues for table&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;for row in rows:&amp;nbsp; #loops through vlaues and updates new field basedon last word of orig field&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; row.Type = row.Dest.split(" ")[-1] if " " in row.Dest else ""&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; rows.updateRow(row)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;del row&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;del rows&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;resulting table has a new field "Type" with the second word from the "dest" row copied over. If no second word nothing is copied over. Thanks for the help all!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 08 Dec 2010 00:23:47 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/split-text-field-into-two-new-fields/m-p/553427#M43211</guid>
      <dc:creator>DavidMedeiros</dc:creator>
      <dc:date>2010-12-08T00:23:47Z</dc:date>
    </item>
    <item>
      <title>Re: Split text field into two new fields?</title>
      <link>https://community.esri.com/t5/python-questions/split-text-field-into-two-new-fields/m-p/553428#M43212</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;hi iam trying to do the same thing.. ive got a text field that contains an address each seperated with a "," i want to split into three new fields between the comers. for example&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;28, king road, new york&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;i want to be able to have the following field's&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;28 &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;king road&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;new york&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Does any one know any python script?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 11 Feb 2011 04:09:24 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/split-text-field-into-two-new-fields/m-p/553428#M43212</guid>
      <dc:creator>charlieLatchford</dc:creator>
      <dc:date>2011-02-11T04:09:24Z</dc:date>
    </item>
    <item>
      <title>Re: Split text field into two new fields?</title>
      <link>https://community.esri.com/t5/python-questions/split-text-field-into-two-new-fields/m-p/553429#M43213</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
text = '28, king road, new york'
split_text = text.split(', ') # -&amp;gt; ['28', 'king road', 'new york']
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;A tip is to test the logic in the python interpreter before putting it together in a scirpt.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 23:55:10 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/split-text-field-into-two-new-fields/m-p/553429#M43213</guid>
      <dc:creator>NiklasNorrthon</dc:creator>
      <dc:date>2021-12-11T23:55:10Z</dc:date>
    </item>
    <item>
      <title>Re: Split text field into two new fields?</title>
      <link>https://community.esri.com/t5/python-questions/split-text-field-into-two-new-fields/m-p/553430#M43214</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hello,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I am trying to split a name field into lastname and firstname.&amp;nbsp; The name field may or may not contain a last name.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;examples:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;"Anderson, Bill"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;"CHS Company"&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I am able to pull out the last name from the field.&amp;nbsp; However I am having trouble getting the first name (if there is any) out.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I tried the code: &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;!TAX_NAME!.split(",", 1)[-1] if "," in !TAX_NAME! else ""&amp;nbsp;&amp;nbsp; however ArcGIS reported a syntax error&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 15 Aug 2011 14:56:36 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/split-text-field-into-two-new-fields/m-p/553430#M43214</guid>
      <dc:creator>MarkVolz</dc:creator>
      <dc:date>2011-08-15T14:56:36Z</dc:date>
    </item>
    <item>
      <title>Re: Split text field into two new fields?</title>
      <link>https://community.esri.com/t5/python-questions/split-text-field-into-two-new-fields/m-p/553431#M43215</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I don't use the CalculateField command very often (IMO UpdateCursors are easier to understand), but I think the syntax you're looking for is:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_macro_code jive_text_macro"&gt;if ',' in !TAX_NAME! then !TAX_NAME!.split(',',1)[-1] else ""&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 15 Aug 2011 15:54:55 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/split-text-field-into-two-new-fields/m-p/553431#M43215</guid>
      <dc:creator>BruceNielsen</dc:creator>
      <dc:date>2011-08-15T15:54:55Z</dc:date>
    </item>
    <item>
      <title>Re: Split text field into two new fields?</title>
      <link>https://community.esri.com/t5/python-questions/split-text-field-into-two-new-fields/m-p/553432#M43216</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Bruce,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thank you for your reply.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I am still getting an error:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;ERROR 000539: Error running expression: if ',' in "PETERSEN,ERIC J &amp;amp; GAIL" then "PETERSEN,ERIC J &amp;amp; GAIL".split(',',1)[-1] else "" &amp;lt;type 'exceptions.SyntaxError'&amp;gt;: invalid syntax (&amp;lt;string&amp;gt;, line 1)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Failed to execute (Calculate Field (2)).&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 15 Aug 2011 16:39:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/split-text-field-into-two-new-fields/m-p/553432#M43216</guid>
      <dc:creator>MarkVolz</dc:creator>
      <dc:date>2011-08-15T16:39:50Z</dc:date>
    </item>
    <item>
      <title>Re: Split text field into two new fields?</title>
      <link>https://community.esri.com/t5/python-questions/split-text-field-into-two-new-fields/m-p/553433#M43217</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Like I said, I don't use this syntax very often. Here's the amended code:&lt;/SPAN&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_macro_code jive_text_macro"&gt;if ',' in !TAX_NAME! then !&lt;SPAN style="font-style:italic;"&gt;NEW_FIELD&lt;/SPAN&gt;!=!TAX_NAME!.split(',',1)[-1] else "".&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 15 Aug 2011 17:25:56 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/split-text-field-into-two-new-fields/m-p/553433#M43217</guid>
      <dc:creator>BruceNielsen</dc:creator>
      <dc:date>2011-08-15T17:25:56Z</dc:date>
    </item>
  </channel>
</rss>

