<?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: How can I use Python to separate thousands with commas in an attribute table in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/how-can-i-use-python-to-separate-thousands-with/m-p/267494#M20584</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;In Python you don't have access to change the properties of how a field is displayed. You can update the contents of the field or create additional fields as Dan mentioned. In ArcMap you would need ArcObjects to do this. How many fields do you have?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 10 Jan 2018 14:44:54 GMT</pubDate>
    <dc:creator>XanderBakker</dc:creator>
    <dc:date>2018-01-10T14:44:54Z</dc:date>
    <item>
      <title>How can I use Python to separate thousands with commas in an attribute table</title>
      <link>https://community.esri.com/t5/python-questions/how-can-i-use-python-to-separate-thousands-with/m-p/267492#M20582</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I want to format a large number of fields in an attribute table so that&amp;nbsp; they display with thousands separated by commas.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Is there any way to do this using python?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;To do it via the GUI you would 1. display the attribute table, 2. right click on each field name, 3. select 'properties', 4. click on the '...' icon next to 'numeric', 5.click on 'show thousands separators' 6. select 'OK', 7. select 'OK' again.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I want to automate it so that the Python script would do this for all fields with an index number &amp;gt; 5 - that is, ignoring the first few fields which contain non-numeric data.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The reason I want to do this is that I want the field values to be displayed with thousands separators when they are displayed as labels in a map.&amp;nbsp;&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, 10 Jan 2018 12:41:55 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-can-i-use-python-to-separate-thousands-with/m-p/267492#M20582</guid>
      <dc:creator>JamieTratalos</dc:creator>
      <dc:date>2018-01-10T12:41:55Z</dc:date>
    </item>
    <item>
      <title>Re: How can I use Python to separate thousands with commas in an attribute table</title>
      <link>https://community.esri.com/t5/python-questions/how-can-i-use-python-to-separate-thousands-with/m-p/267493#M20583</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;python allows that for strings in python 2.x,&amp;nbsp;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;&lt;SPAN class="string token"&gt;"{:,}"&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="number token"&gt;123456789&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;

&lt;SPAN class="string token"&gt;'123,456,789'&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;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;but you will have to wait for python 3.6+ to get other options&lt;/P&gt;&lt;P&gt;&lt;A href="https://www.python.org/dev/peps/pep-0515/" rel="nofollow noopener noreferrer" target="_blank"&gt;https://www.python.org/dev/peps/pep-0515/&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So if you want your numbers to have commas, then you have to make a text/string field to put the expression in&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 13:06:51 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-can-i-use-python-to-separate-thousands-with/m-p/267493#M20583</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2021-12-11T13:06:51Z</dc:date>
    </item>
    <item>
      <title>Re: How can I use Python to separate thousands with commas in an attribute table</title>
      <link>https://community.esri.com/t5/python-questions/how-can-i-use-python-to-separate-thousands-with/m-p/267494#M20584</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;In Python you don't have access to change the properties of how a field is displayed. You can update the contents of the field or create additional fields as Dan mentioned. In ArcMap you would need ArcObjects to do this. How many fields do you have?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 10 Jan 2018 14:44:54 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-can-i-use-python-to-separate-thousands-with/m-p/267494#M20584</guid>
      <dc:creator>XanderBakker</dc:creator>
      <dc:date>2018-01-10T14:44:54Z</dc:date>
    </item>
    <item>
      <title>Re: How can I use Python to separate thousands with commas in an attribute table</title>
      <link>https://community.esri.com/t5/python-questions/how-can-i-use-python-to-separate-thousands-with/m-p/267495#M20585</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;What you are after is &lt;A href="https://desktop.arcgis.com/en/arcobjects/latest/net/webframe.htm#ifieldinfo_numberformat.htm"&gt;IFieldInfo.NumberFormat Property (ArcObjects .NET 10.5 SDK&lt;/A&gt;).&amp;nbsp; Unfortunately, Esri hasn't implemented that through ArcPy so the best you can do for now is either manually make the changes in the GUI or follow Dan's suggestion.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 10 Jan 2018 14:46:31 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-can-i-use-python-to-separate-thousands-with/m-p/267495#M20585</guid>
      <dc:creator>JoshuaBixby</dc:creator>
      <dc:date>2018-01-10T14:46:31Z</dc:date>
    </item>
    <item>
      <title>Re: How can I use Python to separate thousands with commas in an attribute table</title>
      <link>https://community.esri.com/t5/python-questions/how-can-i-use-python-to-separate-thousands-with/m-p/267496#M20586</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;around 200 fields at the moment, but probably more in future work.&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 10 Jan 2018 15:48:07 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-can-i-use-python-to-separate-thousands-with/m-p/267496#M20586</guid>
      <dc:creator>JamieTratalos</dc:creator>
      <dc:date>2018-01-10T15:48:07Z</dc:date>
    </item>
    <item>
      <title>Re: How can I use Python to separate thousands with commas in an attribute table</title>
      <link>https://community.esri.com/t5/python-questions/how-can-i-use-python-to-separate-thousands-with/m-p/267497#M20587</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;That is a lot of fields... I can imagine that you don't want to do that manually. However, how are you going to present this to the "end-user" how are they going to use this data? Having 200 fields or more with data may not be the easiest way to use the data. Can you explain a little more about the use case and what type of data you have?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Adding the text fields (as per the suggestions by Dan and Joshua) can be scripted, but then you will end up with twice the amount of fields...&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 10 Jan 2018 16:09:56 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-can-i-use-python-to-separate-thousands-with/m-p/267497#M20587</guid>
      <dc:creator>XanderBakker</dc:creator>
      <dc:date>2018-01-10T16:09:56Z</dc:date>
    </item>
    <item>
      <title>Re: How can I use Python to separate thousands with commas in an attribute table</title>
      <link>https://community.esri.com/t5/python-questions/how-can-i-use-python-to-separate-thousands-with/m-p/267498#M20588</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If there are 200 fields and more to come, I would strongly recommend that you have an alternate way for the client or you to 'view' the tabular information.&amp;nbsp; Options would include&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;scale the data...&lt;UL&gt;&lt;LI style="text-align: left;"&gt;ie instead of&amp;nbsp; meters.... change the field to kilometers&lt;/LI&gt;&lt;LI style="text-align: left;"&gt;kilograms to tonnes&lt;/LI&gt;&lt;LI style="text-align: left;"&gt;small to big .... whatever moves the commas and decimals&lt;/LI&gt;&lt;/UL&gt;&lt;/LI&gt;&lt;LI style="text-align: left;"&gt;can't those popup things (? what are they called) present 'text' in the format I describe&amp;nbsp;&lt;/LI&gt;&lt;LI style="text-align: left;"&gt;telling the client that it isn't possible given the current budget... or if it is just you... move on &lt;IMG src="https://community.esri.com/legacyfs/online/emoticons/wink.png" /&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;OR&lt;/P&gt;&lt;P&gt;You could&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;export everything out to a numpy array,&lt;/LI&gt;&lt;LI&gt;do the data type conversion there and&lt;/LI&gt;&lt;LI&gt;bring in the new tabular information as a table join&lt;UL&gt;&lt;LI&gt;(all this would use is TableToNumPyArray,&lt;/LI&gt;&lt;LI&gt;I can guide on the type conversion,&lt;/LI&gt;&lt;LI&gt;followed by an arcpy ExtendTable to bring the tabular information back in as a join&lt;/LI&gt;&lt;/UL&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;Multiple options, depending who the target audience is and how big a deal it is.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 10 Jan 2018 16:19:14 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-can-i-use-python-to-separate-thousands-with/m-p/267498#M20588</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2018-01-10T16:19:14Z</dc:date>
    </item>
  </channel>
</rss>

