<?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 Trying to revise the placement of numbers and letters in a field  in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/trying-to-revise-the-placement-of-numbers-and/m-p/45282#M3568</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;I am new at Python. I have a dbf table with a text field.&amp;nbsp; Some of the records contain one or two digit numbers at the beginning followed by a string various capital letters which may then be followed by one or two digit numbers and another string of capital letters. Example: 12NESW3SESE. This is just one example of many combinations of numbers and letters. I need to change the order of the records so that the initial one or two digit number follows, rather than precedes, the letters until it gets to the second instance of a one or two digit number. Likewise, the second instance of one or two digit numbers needs to be moved to the end of the second sequence of capital letters. Also, in all cases a semicolon needs to precede the one or two digit number and a comma after the first set of one or two digit numbers and before the second set of capital letters. Hence, the example should be revised to NESW;12,SESE;3&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 10 Aug 2016 20:29:15 GMT</pubDate>
    <dc:creator>jamesschoolar</dc:creator>
    <dc:date>2016-08-10T20:29:15Z</dc:date>
    <item>
      <title>Trying to revise the placement of numbers and letters in a field</title>
      <link>https://community.esri.com/t5/python-questions/trying-to-revise-the-placement-of-numbers-and/m-p/45282#M3568</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;I am new at Python. I have a dbf table with a text field.&amp;nbsp; Some of the records contain one or two digit numbers at the beginning followed by a string various capital letters which may then be followed by one or two digit numbers and another string of capital letters. Example: 12NESW3SESE. This is just one example of many combinations of numbers and letters. I need to change the order of the records so that the initial one or two digit number follows, rather than precedes, the letters until it gets to the second instance of a one or two digit number. Likewise, the second instance of one or two digit numbers needs to be moved to the end of the second sequence of capital letters. Also, in all cases a semicolon needs to precede the one or two digit number and a comma after the first set of one or two digit numbers and before the second set of capital letters. Hence, the example should be revised to NESW;12,SESE;3&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 10 Aug 2016 20:29:15 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/trying-to-revise-the-placement-of-numbers-and/m-p/45282#M3568</guid>
      <dc:creator>jamesschoolar</dc:creator>
      <dc:date>2016-08-10T20:29:15Z</dc:date>
    </item>
    <item>
      <title>Re: Trying to revise the placement of numbers and letters in a field</title>
      <link>https://community.esri.com/t5/python-questions/trying-to-revise-the-placement-of-numbers-and/m-p/45283#M3569</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If they were all the a fixed format in that order, you could keep it simple...but there will be others that have many more creative ways to do this if not fixed.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;aa = "12NESW3SESE"
bb = ("{0};{1};{2};{3}".format(aa[2:6], aa[0:2], aa[7:11], aa[6:7]))
print bb&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Check out &lt;A href="https://community.esri.com/migration-blogpost/55413" target="_blank"&gt;The ...py... links&lt;/A&gt;&amp;nbsp;&amp;nbsp; for a link to many others python topics.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Dec 2021 21:45:32 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/trying-to-revise-the-placement-of-numbers-and/m-p/45283#M3569</guid>
      <dc:creator>RebeccaStrauch__GISP</dc:creator>
      <dc:date>2021-12-10T21:45:32Z</dc:date>
    </item>
    <item>
      <title>Re: Trying to revise the placement of numbers and letters in a field</title>
      <link>https://community.esri.com/t5/python-questions/trying-to-revise-the-placement-of-numbers-and/m-p/45284#M3570</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Nice Rebecca... python's mini-formatting language at its best!&lt;/P&gt;&lt;P&gt;The only thing I might add to Rebecca's solution is to sort and select the conditions that meet your requirements. &lt;/P&gt;&lt;P&gt;2 digit number&amp;nbsp; 4 text&lt;/P&gt;&lt;P&gt;1 digit number 4 text&amp;nbsp;&amp;nbsp; then rearrange&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if you happen to get&lt;/P&gt;&lt;P&gt;2 digit number 4 text&lt;/P&gt;&lt;P&gt;2 digit number 4 test&amp;nbsp;&amp;nbsp; like 12NESW15SESE&lt;/P&gt;&lt;P&gt;then you only have to make a slight change to her formula aa[2:6]], aa[0:2], aa[8:12], aa[6:8]&lt;/P&gt;&lt;P&gt;to account for it.&amp;nbsp; I suspect you only with have two or at most 3 differing conditions so some big wonking script to do it in one go would be nice, but sometimes a quick select, edit, apply keeps the mind sharp&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 10 Aug 2016 21:12:10 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/trying-to-revise-the-placement-of-numbers-and/m-p/45284#M3570</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2016-08-10T21:12:10Z</dc:date>
    </item>
    <item>
      <title>Re: Trying to revise the placement of numbers and letters in a field</title>
      <link>https://community.esri.com/t5/python-questions/trying-to-revise-the-placement-of-numbers-and/m-p/45285#M3571</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm sure this could use some refinement, but I think is approximately what you're after:&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; aa = "12NESW3SESE"
... prev_type = aa[0].isdigit()
... list_1 = []
... cur_word = ''
... for char in aa:
...&amp;nbsp;&amp;nbsp;&amp;nbsp; if char.isdigit() == prev_type:
...&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; cur_word += char
...&amp;nbsp;&amp;nbsp;&amp;nbsp; else:
...&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; list_1.append(cur_word)
...&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; cur_word = char
...&amp;nbsp;&amp;nbsp;&amp;nbsp; prev_type = char.isdigit()
... list_1.append(cur_word)
... print list_1
... list_2 = []
... for i in range(0,len(list_1),2):
...&amp;nbsp;&amp;nbsp;&amp;nbsp; list_2.append(list_1[i+1] + ';' + list_1&lt;I&gt;)&lt;/I&gt;
... print list_2
... final_list = ','.join(list_2)
... print final_list
...
['12', 'NESW', '3', 'SESE']
['NESW;12', 'SESE;3']
NESW;12,SESE;3&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Dec 2021 21:45:34 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/trying-to-revise-the-placement-of-numbers-and/m-p/45285#M3571</guid>
      <dc:creator>DarrenWiens2</dc:creator>
      <dc:date>2021-12-10T21:45:34Z</dc:date>
    </item>
    <item>
      <title>Re: Trying to revise the placement of numbers and letters in a field</title>
      <link>https://community.esri.com/t5/python-questions/trying-to-revise-the-placement-of-numbers-and/m-p/45286#M3572</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks for the catch... &lt;IMG src="https://community.esri.com/legacyfs/online/emoticons/silly.png" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 10 Aug 2016 21:33:43 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/trying-to-revise-the-placement-of-numbers-and/m-p/45286#M3572</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2016-08-10T21:33:43Z</dc:date>
    </item>
    <item>
      <title>Re: Trying to revise the placement of numbers and letters in a field</title>
      <link>https://community.esri.com/t5/python-questions/trying-to-revise-the-placement-of-numbers-and/m-p/45287#M3573</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Darren,&amp;nbsp;&amp;nbsp; out_list should be list_1 in the code above&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;aa = "12NESW3SESE"
prev_type = aa[0].isdigit()
list_1 = []
cur_word = ''
for char in aa:
&amp;nbsp;&amp;nbsp; if char.isdigit() == prev_type:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; cur_word += char
&amp;nbsp;&amp;nbsp; else:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; list_1.append(cur_word)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; cur_word = char
&amp;nbsp;&amp;nbsp; prev_type = char.isdigit()
list_1.append(cur_word)
print list_1
list_2 = []
for i in range(0,len(list_1),2):
&amp;nbsp;&amp;nbsp; list_2.append(list_1[i+1] + ';' + list_1&lt;I&gt;)&lt;/I&gt;
print list_2
final_list = ','.join(list_2)
print final_list&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;kept eating my reply...looks like it worked this time.&amp;nbsp; guess that's what I get for trying to delete one of my other replies!!&amp;nbsp; &lt;IMG src="https://community.esri.com/legacyfs/online/emoticons/shocked.png" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Dec 2021 21:45:37 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/trying-to-revise-the-placement-of-numbers-and/m-p/45287#M3573</guid>
      <dc:creator>RebeccaStrauch__GISP</dc:creator>
      <dc:date>2021-12-10T21:45:37Z</dc:date>
    </item>
    <item>
      <title>Re: Trying to revise the placement of numbers and letters in a field</title>
      <link>https://community.esri.com/t5/python-questions/trying-to-revise-the-placement-of-numbers-and/m-p/45288#M3574</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Oops. thanks. So much for editing for clarity. &lt;IMG src="https://community.esri.com/legacyfs/online/emoticons/happy.png" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 10 Aug 2016 21:39:25 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/trying-to-revise-the-placement-of-numbers-and/m-p/45288#M3574</guid>
      <dc:creator>DarrenWiens2</dc:creator>
      <dc:date>2016-08-10T21:39:25Z</dc:date>
    </item>
    <item>
      <title>Re: Trying to revise the placement of numbers and letters in a field</title>
      <link>https://community.esri.com/t5/python-questions/trying-to-revise-the-placement-of-numbers-and/m-p/45289#M3575</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks Rebecca, This is very helpful. Unfortunately, it is not a fixed format. The second record might be something like SW6SWNENENE or even records with no capital letter such as 1. The target format for these two examples would be SW,SWNENENE;6 and simply ;1 , Bob&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 10 Aug 2016 21:47:00 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/trying-to-revise-the-placement-of-numbers-and/m-p/45289#M3575</guid>
      <dc:creator>jamesschoolar</dc:creator>
      <dc:date>2016-08-10T21:47:00Z</dc:date>
    </item>
    <item>
      <title>Re: Trying to revise the placement of numbers and letters in a field</title>
      <link>https://community.esri.com/t5/python-questions/trying-to-revise-the-placement-of-numbers-and/m-p/45290#M3576</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks Darren, Looks very much like the code I might need. However, as I am still in a steep learning curve, I will have to digest and understand along with other comments to put this to work land records. Bob&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 10 Aug 2016 21:58:31 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/trying-to-revise-the-placement-of-numbers-and/m-p/45290#M3576</guid>
      <dc:creator>jamesschoolar</dc:creator>
      <dc:date>2016-08-10T21:58:31Z</dc:date>
    </item>
    <item>
      <title>Re: Trying to revise the placement of numbers and letters in a field</title>
      <link>https://community.esri.com/t5/python-questions/trying-to-revise-the-placement-of-numbers-and/m-p/45291#M3577</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;field calculator script... oh well&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; numpy &lt;SPAN class="keyword token"&gt;as&lt;/SPAN&gt; np
&lt;SPAN class="keyword token"&gt;def&lt;/SPAN&gt; &lt;SPAN class="token function"&gt;shuffle&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;aa&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="string token"&gt;""" useage&amp;nbsp;&amp;nbsp; shuffle(!YourField!) """&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; a &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; np&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;array&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;list&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;aa&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; b &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;int&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;i&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;isalpha&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt; &lt;SPAN class="keyword token"&gt;for&lt;/SPAN&gt; i &lt;SPAN class="keyword token"&gt;in&lt;/SPAN&gt; a&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&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="punctuation token"&gt;]&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; c &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;int&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;i&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;isalpha&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt; &lt;SPAN class="keyword token"&gt;for&lt;/SPAN&gt; i &lt;SPAN class="keyword token"&gt;in&lt;/SPAN&gt; a&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="punctuation token"&gt;]&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; d &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; np&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;sum&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;np&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;array&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;list&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;zip&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;b&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="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; axis&lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;1&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; e &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;np&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;where&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;d &lt;SPAN class="operator 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="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="operator token"&gt;+&lt;/SPAN&gt; &lt;SPAN class="number token"&gt;1&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; e &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; e&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;tolist&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; spl &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; np&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;split&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;a&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;e&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; out &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="keyword token"&gt;for&lt;/SPAN&gt; s &lt;SPAN class="keyword token"&gt;in&lt;/SPAN&gt; spl&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; out&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;append&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;&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;i &lt;SPAN class="keyword token"&gt;for&lt;/SPAN&gt; i &lt;SPAN class="keyword token"&gt;in&lt;/SPAN&gt; s&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;
&amp;nbsp;&amp;nbsp;&amp;nbsp; out &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"{1} {0} {3} {2}"&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="operator token"&gt;*&lt;/SPAN&gt;out&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="keyword token"&gt;return&lt;/SPAN&gt; out
&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;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Done verbosely so people can understand&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;line 04&amp;nbsp; convert string to a list, then an array&lt;/P&gt;&lt;P&gt;line 05, 06&amp;nbsp; and 07&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; do a check for numbers offset by 1 in the sequence&amp;nbsp; True and False from isalpha is converted to an integer so they can be&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; added together after forming an n*2 array and summing by row.&amp;nbsp; This will yield 0,1,2&lt;/P&gt;&lt;P&gt;line 09&amp;nbsp;&amp;nbsp; all we really care about is where things change, which is where d is 1, but we have to add 1 to the whole sequence&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;&amp;nbsp;&amp;nbsp; for slicing&amp;nbsp; (long story, just trust me)&lt;/P&gt;&lt;P&gt;line 10&amp;nbsp;&amp;nbsp; do the split&lt;/P&gt;&lt;P&gt;lines 12-13&amp;nbsp; a little list comprehension stuff because they are fast and the data size (aa) is know to be small&lt;/P&gt;&lt;P&gt;line 14&amp;nbsp;&amp;nbsp;&amp;nbsp; Do the format Rebecca did on the output which you can automagically parse into bits with the *&lt;/P&gt;&lt;P&gt;line 15&amp;nbsp;&amp;nbsp;&amp;nbsp; send it back&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;internals&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;input a&amp;nbsp;&amp;nbsp; ['1' '2' '3' 'N' 'E' 'S' 'W' '3' '3' 'S' 'E' 'S' 'E']&lt;/P&gt;&lt;P&gt;check b&amp;nbsp;&amp;nbsp; [0, 0, 0, 1, 1, 1, 1, 0, 0, 1, 1, 1]&lt;/P&gt;&lt;P&gt;check c&amp;nbsp;&amp;nbsp; [0, 0, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1]&lt;/P&gt;&lt;P&gt;sums&amp;nbsp; d&amp;nbsp;&amp;nbsp; [0 0 1 2 2 2 1 0 1 2 2 2]&lt;/P&gt;&lt;P&gt;where e&amp;nbsp;&amp;nbsp; [3, 7, 9]&lt;/P&gt;&lt;P&gt;split spl NESW 123 SESE 33&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;sample result&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;input 123NESW33SESE&lt;/P&gt;&lt;P&gt;output NESW 123 SESE 33&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if you don't like the spaces, remove them in line 14 between the {1} {0} etc or you can put commas in whatever.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;into a text field&lt;/P&gt;&lt;P&gt;python parser&lt;/P&gt;&lt;P&gt;show code block&lt;/P&gt;&lt;P&gt;copy the above code into the code block&lt;/P&gt;&lt;P&gt;useage in expression box of the field calculator:&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; shuffle(!YourField!)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You can copy this after line 15 if you just want to test in a script first... I did 2 tests, you should do more&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;&lt;SPAN class="comment token"&gt;#----------------------&lt;/SPAN&gt;
&lt;SPAN class="keyword token"&gt;if&lt;/SPAN&gt; __name__ &lt;SPAN class="operator token"&gt;==&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"__main__"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="string token"&gt;"""Main section...&amp;nbsp; """&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; aa &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"12NESW3SESE"&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; aa &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"123NESW33SESE"&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; out &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; shuffle&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;aa&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="keyword token"&gt;print&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"input {}\noutput {}"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;format&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;aa&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; out&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;/CODE&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Dec 2021 21:45:40 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/trying-to-revise-the-placement-of-numbers-and/m-p/45291#M3577</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2021-12-10T21:45:40Z</dc:date>
    </item>
    <item>
      <title>Re: Trying to revise the placement of numbers and letters in a field</title>
      <link>https://community.esri.com/t5/python-questions/trying-to-revise-the-placement-of-numbers-and/m-p/45292#M3578</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Dan, Thanks for the script and taking time to explain verbosely. I am making progress for sure with all this great help. I've got 370 thousand records to process on the first set and 13 sets to process. Such powerful coding. Bob&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 11 Aug 2016 03:46:17 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/trying-to-revise-the-placement-of-numbers-and/m-p/45292#M3578</guid>
      <dc:creator>jamesschoolar</dc:creator>
      <dc:date>2016-08-11T03:46:17Z</dc:date>
    </item>
    <item>
      <title>Re: Trying to revise the placement of numbers and letters in a field</title>
      <link>https://community.esri.com/t5/python-questions/trying-to-revise-the-placement-of-numbers-and/m-p/45293#M3579</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;let me know if you find any case where it doesn't work,&amp;nbsp; it can always be tweeked&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 11 Aug 2016 03:48:33 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/trying-to-revise-the-placement-of-numbers-and/m-p/45293#M3579</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2016-08-11T03:48:33Z</dc:date>
    </item>
    <item>
      <title>Re: Trying to revise the placement of numbers and letters in a field</title>
      <link>https://community.esri.com/t5/python-questions/trying-to-revise-the-placement-of-numbers-and/m-p/45294#M3580</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If I had to tackle this I'd consider&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1. How many records do I need to edit?&lt;/P&gt;&lt;P&gt;2. And I going to have to do this again and frequently?&lt;/P&gt;&lt;P&gt;3. Are all records the same length?&lt;/P&gt;&lt;P&gt;4. Do I need any numbers to be zfilled, e.g. 01 vs 1&lt;/P&gt;&lt;P&gt;5. Is Python the most appropriate tool for this?&lt;/P&gt;&lt;P&gt;6. Do I expect there to be any errors/inconsistencies in the existing data?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;- If it's only a small number of records, e.g. less than 500 and you only need to do it this one time, then it may be easier to just edit it manually.&lt;/P&gt;&lt;P&gt;- If the records are all different lengths, or if you need to do z-filling, then that increases the complexity of the Python code&lt;/P&gt;&lt;P&gt;- If your or someone you know is good at Excel, then you may be able to use that. Also, if you are within the ArcGIS environment, you may consider just exploding the string into multiple columns, and then using field calculations to put them back as you want.&lt;/P&gt;&lt;P&gt;- if there are alot of errors in the data then you need to make sure the code can catch and alert you to the problem strings. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I saw in your last post that you've got 370k x 13 sets to process, so not all of this is applicable, but I think it is important to consider since these threads can be searched by someone years from now.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;George&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 11 Aug 2016 13:30:22 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/trying-to-revise-the-placement-of-numbers-and/m-p/45294#M3580</guid>
      <dc:creator>GeorgeNewbury</dc:creator>
      <dc:date>2016-08-11T13:30:22Z</dc:date>
    </item>
  </channel>
</rss>

