<?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: add integers to a Numeric field in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/add-integers-to-a-numeric-field/m-p/1243113#M66326</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;Doing this in field calculator is definitely the best option! Is the AccountID field a text field? Because if it's an integer field you won't be able to add zeros onto the front, and in that case you would need to add a text field to calculate the values into.&lt;/P&gt;&lt;P&gt;As for some code to do what you're trying to do, if you put this in the code block using Python3:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;def addZeros(ID):
    ID = str(ID)
    noZeros = 10 - len(ID)
    return "0" * noZeros + ID&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;and then the following as the python expression to run above the code block box&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;addZeros(!IDNum!)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;With the !IDNum! being the Account ID field, that should do what you're after!&lt;/P&gt;&lt;P&gt;Cheers,&lt;/P&gt;&lt;P&gt;Josh&lt;/P&gt;</description>
    <pubDate>Wed, 21 Dec 2022 21:53:39 GMT</pubDate>
    <dc:creator>JoshuaSharp-Heward</dc:creator>
    <dc:date>2022-12-21T21:53:39Z</dc:date>
    <item>
      <title>add integers to a Numeric field</title>
      <link>https://community.esri.com/t5/python-questions/add-integers-to-a-numeric-field/m-p/1243086#M66325</link>
      <description>&lt;P&gt;1.&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="dalvarez_0-1671654945467.png" style="width: 132px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/59056iC8AED7D96221949C/image-dimensions/132x187?v=v2" width="132" height="187" role="button" title="dalvarez_0-1671654945467.png" alt="dalvarez_0-1671654945467.png" /&gt;&lt;/span&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;2.&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="dalvarez_1-1671655019435.png" style="width: 97px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/59057i20D9D8047C173646/image-dimensions/97x268?v=v2" width="97" height="268" role="button" title="dalvarez_1-1671655019435.png" alt="dalvarez_1-1671655019435.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;I need all of the values in example one to have 10 integers like the ones one table two. To do So I need to add the necessary amount of ceros before the value.&amp;nbsp; there are values that need 5, 4, or 1 cero to be added. Any ideas of geoprocessing tools that do this or how to do it by calculating the field ?&lt;/P&gt;&lt;P&gt;Thanks!!!!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;same numeric values but the numbers cave ceros in front.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 21 Dec 2022 20:44:42 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/add-integers-to-a-numeric-field/m-p/1243086#M66325</guid>
      <dc:creator>dalvarez</dc:creator>
      <dc:date>2022-12-21T20:44:42Z</dc:date>
    </item>
    <item>
      <title>Re: add integers to a Numeric field</title>
      <link>https://community.esri.com/t5/python-questions/add-integers-to-a-numeric-field/m-p/1243113#M66326</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;Doing this in field calculator is definitely the best option! Is the AccountID field a text field? Because if it's an integer field you won't be able to add zeros onto the front, and in that case you would need to add a text field to calculate the values into.&lt;/P&gt;&lt;P&gt;As for some code to do what you're trying to do, if you put this in the code block using Python3:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;def addZeros(ID):
    ID = str(ID)
    noZeros = 10 - len(ID)
    return "0" * noZeros + ID&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;and then the following as the python expression to run above the code block box&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;addZeros(!IDNum!)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;With the !IDNum! being the Account ID field, that should do what you're after!&lt;/P&gt;&lt;P&gt;Cheers,&lt;/P&gt;&lt;P&gt;Josh&lt;/P&gt;</description>
      <pubDate>Wed, 21 Dec 2022 21:53:39 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/add-integers-to-a-numeric-field/m-p/1243113#M66326</guid>
      <dc:creator>JoshuaSharp-Heward</dc:creator>
      <dc:date>2022-12-21T21:53:39Z</dc:date>
    </item>
    <item>
      <title>Re: add integers to a Numeric field</title>
      <link>https://community.esri.com/t5/python-questions/add-integers-to-a-numeric-field/m-p/1243175#M66327</link>
      <description>&lt;LI-CODE lang="python"&gt;# == example
a = [1, 12, 123, 1234, 12345, 123456, 1234567, 12345678, 123456789]
frmt = "{:010d}"

[frmt.format(i) for i in a]
 
['0000000001',
 '0000000012',
 '0000000123',
 '0000001234',
 '0000012345',
 '0000123456',
 '0001234567',
 '0012345678',
 '0123456789']

# --- field calculator useage

"{:010d}".format(!YourFieldWithNumbers!)&lt;/LI-CODE&gt;</description>
      <pubDate>Thu, 22 Dec 2022 02:31:14 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/add-integers-to-a-numeric-field/m-p/1243175#M66327</guid>
      <dc:creator>DanPatterson</dc:creator>
      <dc:date>2022-12-22T02:31:14Z</dc:date>
    </item>
    <item>
      <title>Re: add integers to a Numeric field</title>
      <link>https://community.esri.com/t5/python-questions/add-integers-to-a-numeric-field/m-p/1243292#M66331</link>
      <description>&lt;P&gt;An easy way using Arcade uses &lt;A href="https://developers.arcgis.com/arcade/function-reference/text_functions/#text" target="_self"&gt;Text&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var num = 1234;
return Text(num,'0000000000');&lt;/LI-CODE&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="2022-12-22_7-10-32.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/59158iE3B8F762BE367872/image-size/medium?v=v2&amp;amp;px=400" role="button" title="2022-12-22_7-10-32.png" alt="2022-12-22_7-10-32.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 22 Dec 2022 12:12:39 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/add-integers-to-a-numeric-field/m-p/1243292#M66331</guid>
      <dc:creator>KenBuja</dc:creator>
      <dc:date>2022-12-22T12:12:39Z</dc:date>
    </item>
    <item>
      <title>Re: add integers to a Numeric field</title>
      <link>https://community.esri.com/t5/python-questions/add-integers-to-a-numeric-field/m-p/1243721#M66345</link>
      <description>&lt;P&gt;Thanks!!! This worked.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="dalvarez_0-1672111440125.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/59273i47C1E34A95127184/image-size/medium?v=v2&amp;amp;px=400" role="button" title="dalvarez_0-1672111440125.png" alt="dalvarez_0-1672111440125.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 27 Dec 2022 03:24:25 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/add-integers-to-a-numeric-field/m-p/1243721#M66345</guid>
      <dc:creator>dalvarez</dc:creator>
      <dc:date>2022-12-27T03:24:25Z</dc:date>
    </item>
  </channel>
</rss>

