<?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 Add trailing zeros to field in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/add-trailing-zeros-to-field/m-p/309881#M24140</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have a table BuildingTable with building info. There is a field called "Build_num" with characters like B37828 or B2898101 or R29499010C or&amp;nbsp;R29499010C2 that i need to join to a shapefile but the the Shapefile BuildNum has a max of 11 characters like so B3782800000 or B2898101000. so i can't join the table to shapefile.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;How can update the BuildingTable field "Build_num" to add trailing zeros to that field?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I tried the following, i added a new filed to insert the new Build numbers with the trailing zeros but nothing happened.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;import arcpy&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;fc = "BluidingPermitsTable"&lt;BR /&gt;fields = ('Build_num', 'BuildNum') &lt;BR /&gt;with arcpy.da.UpdateCursor(fc, fields) as cursor:&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; for row in cursor:&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if row[0] &amp;lt;= 11:&lt;BR /&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] = '0' + str(row[0])&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; cursor.updateRow(row)&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, 01 Feb 2017 17:21:23 GMT</pubDate>
    <dc:creator>CCWeedcontrol</dc:creator>
    <dc:date>2017-02-01T17:21:23Z</dc:date>
    <item>
      <title>Add trailing zeros to field</title>
      <link>https://community.esri.com/t5/python-questions/add-trailing-zeros-to-field/m-p/309881#M24140</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have a table BuildingTable with building info. There is a field called "Build_num" with characters like B37828 or B2898101 or R29499010C or&amp;nbsp;R29499010C2 that i need to join to a shapefile but the the Shapefile BuildNum has a max of 11 characters like so B3782800000 or B2898101000. so i can't join the table to shapefile.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;How can update the BuildingTable field "Build_num" to add trailing zeros to that field?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I tried the following, i added a new filed to insert the new Build numbers with the trailing zeros but nothing happened.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;import arcpy&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;fc = "BluidingPermitsTable"&lt;BR /&gt;fields = ('Build_num', 'BuildNum') &lt;BR /&gt;with arcpy.da.UpdateCursor(fc, fields) as cursor:&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; for row in cursor:&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if row[0] &amp;lt;= 11:&lt;BR /&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] = '0' + str(row[0])&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; cursor.updateRow(row)&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, 01 Feb 2017 17:21:23 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/add-trailing-zeros-to-field/m-p/309881#M24140</guid>
      <dc:creator>CCWeedcontrol</dc:creator>
      <dc:date>2017-02-01T17:21:23Z</dc:date>
    </item>
    <item>
      <title>Re: Add trailing zeros to field</title>
      <link>https://community.esri.com/t5/python-questions/add-trailing-zeros-to-field/m-p/309882#M24141</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;To add trailing zeros, try something like:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;BuildNum &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"B37828"&lt;/SPAN&gt;
&lt;SPAN class="keyword token"&gt;print&lt;/SPAN&gt; BuildNum&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;ljust&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;11&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;'0'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;

&lt;SPAN class="keyword token"&gt;print&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"B2898101"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;ljust&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;11&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;'0'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;

&lt;SPAN class="comment token"&gt;# for your code&lt;/SPAN&gt;
row&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="operator token"&gt;=&lt;/SPAN&gt; row&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;ljust&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;11&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;'0'&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;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 14:49:43 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/add-trailing-zeros-to-field/m-p/309882#M24141</guid>
      <dc:creator>RandyBurton</dc:creator>
      <dc:date>2021-12-11T14:49:43Z</dc:date>
    </item>
    <item>
      <title>Re: Add trailing zeros to field</title>
      <link>https://community.esri.com/t5/python-questions/add-trailing-zeros-to-field/m-p/309883#M24142</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Or for current and future versions of python.&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="string token"&gt;"{!s:0&amp;lt;11}"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;format&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;BuildNum&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
&lt;SPAN class="string token"&gt;'B3782800000'&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;/CODE&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 14:49:46 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/add-trailing-zeros-to-field/m-p/309883#M24142</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2021-12-11T14:49:46Z</dc:date>
    </item>
    <item>
      <title>Re: Add trailing zeros to field</title>
      <link>https://community.esri.com/t5/python-questions/add-trailing-zeros-to-field/m-p/309884#M24143</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Knew there had to be a way using .format.&amp;nbsp; Thanks &lt;A href="https://community.esri.com/people/Dan_Patterson"&gt;Dan_Patterson&lt;/A&gt;‌&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 01 Feb 2017 18:43:04 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/add-trailing-zeros-to-field/m-p/309884#M24143</guid>
      <dc:creator>RandyBurton</dc:creator>
      <dc:date>2017-02-01T18:43:04Z</dc:date>
    </item>
    <item>
      <title>Re: Add trailing zeros to field</title>
      <link>https://community.esri.com/t5/python-questions/add-trailing-zeros-to-field/m-p/309885#M24144</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It is being replaced with.... &amp;nbsp;f"stuff formating{}" ... to simplify having to do "stuff formatting {}".format. &amp;nbsp;It is now in la familigia with s", r" and a" formatting. &amp;nbsp;Came out in python 3.6. &amp;nbsp;ArcMap-athians aren't going to see it for a while and Pro is still on 3.4&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;FYI&amp;nbsp;&lt;A class="link-titled" href="https://docs.python.org/3/" title="https://docs.python.org/3/"&gt;Overview — Python 3.6.0 documentation&lt;/A&gt;&amp;nbsp; and 3.7 Dev is there for sneak preview for those that want to pre-book&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 01 Feb 2017 18:48:09 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/add-trailing-zeros-to-field/m-p/309885#M24144</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2017-02-01T18:48:09Z</dc:date>
    </item>
    <item>
      <title>Re: Add trailing zeros to field</title>
      <link>https://community.esri.com/t5/python-questions/add-trailing-zeros-to-field/m-p/309886#M24145</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks to both of you, both options worked great.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 01 Feb 2017 18:48:16 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/add-trailing-zeros-to-field/m-p/309886#M24145</guid>
      <dc:creator>CCWeedcontrol</dc:creator>
      <dc:date>2017-02-01T18:48:16Z</dc:date>
    </item>
    <item>
      <title>Re: Add trailing zeros to field</title>
      <link>https://community.esri.com/t5/python-questions/add-trailing-zeros-to-field/m-p/309887#M24146</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;SPAN style="background-color: #ffffff;"&gt;ArcMap-athians&lt;/SPAN&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&lt;IMG src="https://community.esri.com/legacyfs/online/emoticons/cool.png" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 02 Feb 2017 16:57:36 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/add-trailing-zeros-to-field/m-p/309887#M24146</guid>
      <dc:creator>BlakeTerhune</dc:creator>
      <dc:date>2017-02-02T16:57:36Z</dc:date>
    </item>
  </channel>
</rss>

