<?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: Python to concatenate alternating numeric digits from two separate number fields  in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/python-to-concatenate-alternating-numeric-digits/m-p/199247#M15312</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;ArcGIS Pro? hence, Python 3?&lt;/P&gt;&lt;P&gt;I would have to see the screen grab of the code block section in the field calculator (which it is initially designed for).&lt;/P&gt;&lt;P&gt;So add a new field, select calculate field, copy and paste the code from a text editor (like notepad or notepad++) into the code block.&lt;/P&gt;&lt;P&gt;It says there is a syntax error in line 5... I am trying to rule out things like format issues, wrong line terminators etc.&amp;nbsp; So run a check on the syntax.&lt;/P&gt;&lt;P&gt;the starred expression in line 5... can't remember if it was just a python 3 thing,&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 13 Jun 2019 13:20:09 GMT</pubDate>
    <dc:creator>DanPatterson_Retired</dc:creator>
    <dc:date>2019-06-13T13:20:09Z</dc:date>
    <item>
      <title>Python to concatenate alternating numeric digits from two separate number fields</title>
      <link>https://community.esri.com/t5/python-questions/python-to-concatenate-alternating-numeric-digits/m-p/199243#M15308</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have calc'd the X and Y coordinate value using calc geometry into two separate (numeric / double) fields and now need to combine them into a new string field by alternating the values based upon their individual digit position.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Eample: (note: not using any values after the decimal pt)&lt;/P&gt;&lt;P&gt;Field X_Coor&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;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Field Y_Coor&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;New Combined_Field&lt;/P&gt;&lt;P&gt;1831548.520524&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;490651.99297&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;8439105645&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;End result should have text value template of 'X2Y1X3Y2X4Y3X5Y4X6Y5' ... OR 8&lt;SPAN&gt;439105645 (using the example above)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 12 Jun 2019 18:28:35 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-to-concatenate-alternating-numeric-digits/m-p/199243#M15308</guid>
      <dc:creator>KurtBarclay</dc:creator>
      <dc:date>2019-06-12T18:28:35Z</dc:date>
    </item>
    <item>
      <title>Re: Python to concatenate alternating numeric digits from two separate number fields</title>
      <link>https://community.esri.com/t5/python-questions/python-to-concatenate-alternating-numeric-digits/m-p/199244#M15309</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;&lt;CODE&gt;&lt;SPAN class="keyword token"&gt;def&lt;/SPAN&gt; &lt;SPAN class="token function"&gt;weave&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;a&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; b&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
    &lt;SPAN class="string token"&gt;"""mini-weave"""&lt;/SPAN&gt;
    a &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; str&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;a&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;split&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;&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="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;
    b &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; str&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;b&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;split&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;&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;0&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;&lt;SPAN class="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="keyword token"&gt;return&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;&lt;SPAN class="operator token"&gt;*&lt;/SPAN&gt;sum&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;zip&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;a&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; b&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;&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;
    

weave&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;1831548.520524&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="number token"&gt;490651.99297&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
&lt;SPAN class="string token"&gt;'8439105645'&lt;/SPAN&gt;&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;'weaving' two sequences with conditions.&amp;nbsp; This is a mini-version of a much larger problem.&lt;/P&gt;&lt;P&gt;Line 3... skip the first number in sequence 'a'&lt;/P&gt;&lt;P&gt;Line 4... skip the last number in sequence 'b'&lt;/P&gt;&lt;P&gt;Line 5... the magic&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For a field calculator expression, line 8 would be&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;weave(!a_field!, !b_field!)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any further deviations from your example entail greater condition checking and hence a much longer version&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 09:56:15 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-to-concatenate-alternating-numeric-digits/m-p/199244#M15309</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2021-12-11T09:56:15Z</dc:date>
    </item>
    <item>
      <title>Re: Python to concatenate alternating numeric digits from two separate number fields</title>
      <link>https://community.esri.com/t5/python-questions/python-to-concatenate-alternating-numeric-digits/m-p/199245#M15310</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;PS, I should add you can 'int' or 'float' the string output if you don't need it in string format&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 12 Jun 2019 20:37:45 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-to-concatenate-alternating-numeric-digits/m-p/199245#M15310</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2019-06-12T20:37:45Z</dc:date>
    </item>
    <item>
      <title>Re: Python to concatenate alternating numeric digits from two separate number fields</title>
      <link>https://community.esri.com/t5/python-questions/python-to-concatenate-alternating-numeric-digits/m-p/199246#M15311</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks Dan,&lt;/P&gt;&lt;P&gt;I loaded your script into the Field Calc w/Prelogic and am receiving errors.&lt;/P&gt;&lt;P&gt;I'm working thru it, but if you have an suggestions ... I'll take them.&lt;/P&gt;&lt;P&gt;I really appreciate your help&lt;/P&gt;&lt;P&gt;&lt;IMG class="image-1 jive-image" src="https://community.esri.com/legacyfs/online/450214_pastedImage_1.png" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 13 Jun 2019 12:32:14 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-to-concatenate-alternating-numeric-digits/m-p/199246#M15311</guid>
      <dc:creator>KurtBarclay</dc:creator>
      <dc:date>2019-06-13T12:32:14Z</dc:date>
    </item>
    <item>
      <title>Re: Python to concatenate alternating numeric digits from two separate number fields</title>
      <link>https://community.esri.com/t5/python-questions/python-to-concatenate-alternating-numeric-digits/m-p/199247#M15312</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;ArcGIS Pro? hence, Python 3?&lt;/P&gt;&lt;P&gt;I would have to see the screen grab of the code block section in the field calculator (which it is initially designed for).&lt;/P&gt;&lt;P&gt;So add a new field, select calculate field, copy and paste the code from a text editor (like notepad or notepad++) into the code block.&lt;/P&gt;&lt;P&gt;It says there is a syntax error in line 5... I am trying to rule out things like format issues, wrong line terminators etc.&amp;nbsp; So run a check on the syntax.&lt;/P&gt;&lt;P&gt;the starred expression in line 5... can't remember if it was just a python 3 thing,&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 13 Jun 2019 13:20:09 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-to-concatenate-alternating-numeric-digits/m-p/199247#M15312</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2019-06-13T13:20:09Z</dc:date>
    </item>
  </channel>
</rss>

