<?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 Split Attribute field in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/split-attribute-field/m-p/149659#M11593</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have an Attribute table with several attributes&lt;/P&gt;&lt;P&gt;One of the attributes has the fields&lt;/P&gt;&lt;P&gt;K1-10-11&lt;/P&gt;&lt;P&gt;K1-10-46&lt;/P&gt;&lt;P&gt;K1-10-46c&lt;/P&gt;&lt;P&gt;K1-10-67d (street)&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I Need all of the elements from the field as seperate attributes&lt;/P&gt;&lt;P&gt;eg an Attribute with&lt;/P&gt;&lt;P&gt;K1&lt;/P&gt;&lt;P&gt;K1&lt;BR /&gt;K1&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;another with&lt;/P&gt;&lt;P&gt;10&lt;/P&gt;&lt;P&gt;10&lt;/P&gt;&lt;P&gt;10&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;and a last one with&lt;/P&gt;&lt;P&gt;11&lt;/P&gt;&lt;P&gt;46&lt;/P&gt;&lt;P&gt;46c&lt;/P&gt;&lt;P&gt;67d (without text)&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I cannot do this manually. Is there a way to do this in ArcGIS 10.1 ?&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Furthermore I am wondering if it is possible to connect attribute tables with Excel tables without loading the Excel tables (csv) into ArcGIS?&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 09 Oct 2014 09:19:02 GMT</pubDate>
    <dc:creator>PV</dc:creator>
    <dc:date>2014-10-09T09:19:02Z</dc:date>
    <item>
      <title>Split Attribute field</title>
      <link>https://community.esri.com/t5/python-questions/split-attribute-field/m-p/149659#M11593</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have an Attribute table with several attributes&lt;/P&gt;&lt;P&gt;One of the attributes has the fields&lt;/P&gt;&lt;P&gt;K1-10-11&lt;/P&gt;&lt;P&gt;K1-10-46&lt;/P&gt;&lt;P&gt;K1-10-46c&lt;/P&gt;&lt;P&gt;K1-10-67d (street)&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I Need all of the elements from the field as seperate attributes&lt;/P&gt;&lt;P&gt;eg an Attribute with&lt;/P&gt;&lt;P&gt;K1&lt;/P&gt;&lt;P&gt;K1&lt;BR /&gt;K1&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;another with&lt;/P&gt;&lt;P&gt;10&lt;/P&gt;&lt;P&gt;10&lt;/P&gt;&lt;P&gt;10&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;and a last one with&lt;/P&gt;&lt;P&gt;11&lt;/P&gt;&lt;P&gt;46&lt;/P&gt;&lt;P&gt;46c&lt;/P&gt;&lt;P&gt;67d (without text)&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I cannot do this manually. Is there a way to do this in ArcGIS 10.1 ?&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Furthermore I am wondering if it is possible to connect attribute tables with Excel tables without loading the Excel tables (csv) into ArcGIS?&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 09 Oct 2014 09:19:02 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/split-attribute-field/m-p/149659#M11593</guid>
      <dc:creator>PV</dc:creator>
      <dc:date>2014-10-09T09:19:02Z</dc:date>
    </item>
    <item>
      <title>Re: Split Attribute field</title>
      <link>https://community.esri.com/t5/python-questions/split-attribute-field/m-p/149660#M11594</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;OL&gt;&lt;LI&gt;Add your new fields using Add Field &lt;A href="http://resources.arcgis.com/en/help/main/10.1/index.html#//001700000047000000" title="http://resources.arcgis.com/en/help/main/10.1/index.html#//001700000047000000"&gt;ArcGIS Help 10.1&lt;/A&gt; &lt;/LI&gt;&lt;LI&gt;Use Calculate field to calculate values &lt;A href="http://resources.arcgis.com/en/help/main/10.1/index.html#//005s00000029000000" title="http://resources.arcgis.com/en/help/main/10.1/index.html#//005s00000029000000"&gt;ArcGIS Help 10.1&lt;/A&gt; &lt;/LI&gt;&lt;LI&gt;VBScript Expressions for each field in order&amp;nbsp; &lt;SPAN style="color: #444444; font-family: Consolas, 'courier new'; font-size: 14px; background-color: #f1f1f1;"&gt;Split(&amp;lt;&amp;lt;Your sourceField&amp;gt;&amp;gt;, "-")(0), &lt;SPAN style="color: #444444; font-family: Consolas, 'courier new'; font-size: 14.4444446563721px; background-color: #f1f1f1;"&gt;Split(&amp;lt;&amp;lt;Your sourceField&amp;gt;&amp;gt;, "-")(1) and Trim(Mid(Split( [SURVEY_ID] , "-")(2), 1, InStr(Split( [SURVEY_ID] , "-")(2), "(") - 1))&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/LI&gt;&lt;LI&gt;&lt;SPAN style="color: #444444; font-size: 14.4444446563721px; background-color: #f1f1f1; font-family: Consolas, 'courier new';"&gt;Use Join Field to join with excel sheets &lt;A href="http://resources.arcgis.com/en/help/main/10.1/index.html#//001700000065000000" title="http://resources.arcgis.com/en/help/main/10.1/index.html#//001700000065000000"&gt;ArcGIS Help 10.1&lt;/A&gt; &lt;/SPAN&gt;&lt;/LI&gt;&lt;/OL&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 09 Oct 2014 10:28:20 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/split-attribute-field/m-p/149660#M11594</guid>
      <dc:creator>RiyasDeen</dc:creator>
      <dc:date>2014-10-09T10:28:20Z</dc:date>
    </item>
    <item>
      <title>Re: Split Attribute field</title>
      <link>https://community.esri.com/t5/python-questions/split-attribute-field/m-p/149661#M11595</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;and for the pythonistas&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;

&amp;gt;&amp;gt;&amp;gt; a = ['K1-10-11','K1-10-46','K1-10-46c','K1-10-67d (street)']
&amp;gt;&amp;gt;&amp;gt; for aval in a:
...&amp;nbsp; c0 = aval.split("-")[0]
...&amp;nbsp; c1 = aval.split("-")[1]
...&amp;nbsp; c2 = (aval.split("-")[2]).split(" ")[0]
...&amp;nbsp; print(" first: {0}&amp;nbsp; second: {1}&amp;nbsp; third: {2}".format(c0,c1,c2))
... 


first: K1&amp;nbsp; second: 10&amp;nbsp; third: 11
 first: K1&amp;nbsp; second: 10&amp;nbsp; third: 46
 first: K1&amp;nbsp; second: 10&amp;nbsp; third: 46c
 first: K1&amp;nbsp; second: 10&amp;nbsp; third: 67d
&amp;gt;&amp;gt;&amp;gt; # in arcmap field calculator using Python interpretor
&amp;gt;&amp;gt;&amp;gt; #&amp;nbsp; !sourceFld!.split("-")[0]&amp;nbsp; #for 1st field
&amp;gt;&amp;gt;&amp;gt; #&amp;nbsp; !sourceFld!.split("-")[1]&amp;nbsp; #for 2nd field
&amp;gt;&amp;gt;&amp;gt; #&amp;nbsp; (!sourceFld!.split("-")[2]).split(" ")[0]&amp;nbsp; #for 3rd field

&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 08:05:07 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/split-attribute-field/m-p/149661#M11595</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2021-12-11T08:05:07Z</dc:date>
    </item>
    <item>
      <title>Re: Split Attribute field</title>
      <link>https://community.esri.com/t5/python-questions/split-attribute-field/m-p/149662#M11596</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you it seems to work! Allthough not when I have&lt;/P&gt;&lt;P&gt;a case with text like this K1-10-67d (street)&lt;/P&gt;&lt;P&gt;For the last two fields I get a 0 instead of a 10 and a 67d&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I ve no Phyton experience at all (yet)&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 09 Oct 2014 13:56:59 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/split-attribute-field/m-p/149662#M11596</guid>
      <dc:creator>PV</dc:creator>
      <dc:date>2014-10-09T13:56:59Z</dc:date>
    </item>
    <item>
      <title>Re: Split Attribute field</title>
      <link>https://community.esri.com/t5/python-questions/split-attribute-field/m-p/149663#M11597</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you!&lt;BR /&gt;I am not quite sure how to handle the second and third field&lt;/P&gt;&lt;P&gt;Trim(Mid(Split( [SURVEY_ID] , "-")(2), 1 resp. the 3rd field InStr(Split( [SURVEY_ID] , "-")(2), "(") - 1))&lt;BR /&gt;I guess SURVEY_ID has to be replaced with the original sourcefield Name? . I see what trim and mid do but not what the (2), 1 stands for? Also i get an error when I try to run it in the field calculator..&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 09 Oct 2014 13:59:34 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/split-attribute-field/m-p/149663#M11597</guid>
      <dc:creator>PV</dc:creator>
      <dc:date>2014-10-09T13:59:34Z</dc:date>
    </item>
    <item>
      <title>Re: Split Attribute field</title>
      <link>https://community.esri.com/t5/python-questions/split-attribute-field/m-p/149664#M11598</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;lets have a look in slow motion....&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="python" __jive_macro_name="code" class="jive_macro_code jive_text_macro _jivemacro_uid_14128831997358500" jivemacro_uid="_14128831997358500"&gt;
&lt;P&gt;&amp;gt;&amp;gt;&amp;gt; #lets have a look in verbose form&lt;/P&gt;
&lt;P&gt;&amp;gt;&amp;gt;&amp;gt; a = "K1-10-67d (street)"&lt;/P&gt;
&lt;P&gt;&amp;gt;&amp;gt;&amp;gt; c0 = a.split("-")[0]&lt;/P&gt;
&lt;P&gt;&amp;gt;&amp;gt;&amp;gt; c1 = a.split("-")[1]&lt;/P&gt;
&lt;P&gt;&amp;gt;&amp;gt;&amp;gt; c2all = a.split("-")&lt;/P&gt;
&lt;P&gt;&amp;gt;&amp;gt;&amp;gt; c2a, c2b, c2c = c2all&lt;/P&gt;
&lt;P&gt;&amp;gt;&amp;gt;&amp;gt; print "c0: ", c0&lt;/P&gt;
&lt;P&gt;c0:&amp;nbsp; K1&lt;/P&gt;
&lt;P&gt;&amp;gt;&amp;gt;&amp;gt; print "c1: ", c1&lt;/P&gt;
&lt;P&gt;c1:&amp;nbsp; 10&lt;/P&gt;
&lt;P&gt;&amp;gt;&amp;gt;&amp;gt; print "c2all", c2all&lt;/P&gt;
&lt;P&gt;c2all ['K1', '10', '67d (street)']&lt;/P&gt;
&lt;P&gt;&amp;gt;&amp;gt;&amp;gt; print "c2c: ", c2c.split(" ")[0]&lt;/P&gt;
&lt;P&gt;c2c:&amp;nbsp; 67d&lt;/P&gt;
&lt;P&gt;&amp;gt;&amp;gt;&amp;gt; # hmmmmm works lets try it all at once&lt;/P&gt;
&lt;P&gt;&amp;gt;&amp;gt;&amp;gt; a = "K1-10-67d (street)"&lt;/P&gt;
&lt;P&gt;&amp;gt;&amp;gt;&amp;gt; c0, c1, c2_a_b = a.split("-")&lt;/P&gt;
&lt;P&gt;&amp;gt;&amp;gt;&amp;gt; c2_a, c2_b = c2_a_b.split(" ")&lt;/P&gt;
&lt;P&gt;&amp;gt;&amp;gt;&amp;gt; print (" c0: {0}, c1: {1},&amp;nbsp; c2_a: {2}&amp;nbsp; c2_b: {3}".format(c0, c1, c2_a, c2_b))&lt;/P&gt;
&lt;P&gt;c0: K1, c1: 10,&amp;nbsp; c2_a: 67d&amp;nbsp; c2_b: (street)&lt;/P&gt;
&lt;/PRE&gt;&lt;P&gt;So my original stuff seems to be correct, check your syntax&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 09 Oct 2014 19:32:35 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/split-attribute-field/m-p/149664#M11598</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2014-10-09T19:32:35Z</dc:date>
    </item>
    <item>
      <title>Re: Split Attribute field</title>
      <link>https://community.esri.com/t5/python-questions/split-attribute-field/m-p/149665#M11599</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Seems to work (for most of the cases) when I change my field type to string! thanks!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Oct 2014 07:10:03 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/split-attribute-field/m-p/149665#M11599</guid>
      <dc:creator>PV</dc:creator>
      <dc:date>2014-10-10T07:10:03Z</dc:date>
    </item>
    <item>
      <title>Re: Split Attribute field</title>
      <link>https://community.esri.com/t5/python-questions/split-attribute-field/m-p/149666#M11600</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;So, again, here's the input data (text field name: "DFIELD")&lt;/P&gt;&lt;P style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;&lt;/P&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_macro_code _jivemacro_uid_14134451642587252 jive_text_macro" jivemacro_uid="_14134451642587252"&gt;
&lt;P style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;K1-10-11&lt;/P&gt;
&lt;P style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;K1-10-46&lt;/P&gt;
&lt;P style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;K1-10-46c&lt;/P&gt;
&lt;P style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;K1-10-67d (street)&lt;/P&gt;

&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here's how to do it with with arcpy.da.UpdateCursor.&lt;/P&gt;&lt;P&gt;The try/except just skips the row and prints an error message if you have data issues.&lt;/P&gt;&lt;PRE __default_attr="python" __jive_macro_name="code" class="jive_macro_code _jivemacro_uid_14134454721126049 jive_text_macro" jivemacro_uid="_14134454721126049" modifiedtitle="true"&gt;
&lt;P&gt;for f in ["F1", "F2", "F3"]:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddField_management("table.dbf", f, "TEXT", "", "", 10)&lt;/P&gt;
&lt;P&gt;with arcpy.da.UpdateCursor("table.dbf", ["DFIELD", "F1", "F2", "F3"]) as rows:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; for row in rows:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; try:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; L = row[0].split("-")&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; row[1], row[2], row[3] = L[:3]&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; rows.updateRow(row)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; except Exception as msg:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print("{} | {}".format(row[0], msg))&lt;/P&gt;

&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 Oct 2014 07:49:56 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/split-attribute-field/m-p/149666#M11600</guid>
      <dc:creator>curtvprice</dc:creator>
      <dc:date>2014-10-16T07:49:56Z</dc:date>
    </item>
  </channel>
</rss>

