<?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 to control numeric format using arcpy in ArcGIS Pro Questions</title>
    <link>https://community.esri.com/t5/arcgis-pro-questions/how-to-control-numeric-format-using-arcpy/m-p/1545842#M88924</link>
    <description>&lt;P&gt;This is it!!&lt;/P&gt;&lt;P&gt;Exactly what I was looking for. Although you made me work a bit late for a friday afternoon, I am still grateful.&lt;/P&gt;</description>
    <pubDate>Fri, 04 Oct 2024 21:01:33 GMT</pubDate>
    <dc:creator>AntoinePrince1805</dc:creator>
    <dc:date>2024-10-04T21:01:33Z</dc:date>
    <item>
      <title>How to control numeric format using arcpy</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/how-to-control-numeric-format-using-arcpy/m-p/1544976#M88812</link>
      <description>&lt;P&gt;Does anyone knows of a way to control numeric format for DOUBLE or FLOAT values using only arcpy outside of ArcGIS Pro? I would like to find any ways to control the allowed number of decimals and also the thousand separator. As of now, I have explored two options :&lt;/P&gt;&lt;P&gt;1. Specifying the scale of the field when creating a new field using the "AddField" function, but I found out that the "scale" and "precision" parameters are ignored when using on a feature class inside a geodatabase.&lt;/P&gt;&lt;P&gt;2. Using the layer CIM to access the numberFormat properties with the following script, but the fieldDescriptions list always return empty. After reading a bit on the problem, this seems more like a feature than a bug (eventhough I don't get why we cannot acces the list in a python script, bu we can in the python command promt, inside ArcGIS Pro).&lt;/P&gt;&lt;LI-CODE lang="python"&gt;aprx_path = [PATH_TO_APRX]
aprx = arcpy.mp.ArcGISProject(aprx_path)
map = aprx.listMaps()[0]
lyr = map.listLayers("MyLayer")[0]

lyr_cim = lyr.getDefinition('V3')

for fd in lyr_cim.featureTable.fieldDescriptions:
    fdNumFmt = fd.numberFormat
    fdNumFmt.useSeparator = True
    fdNumFmt.roundingValue = 2&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;So here I am, stuck...&lt;/P&gt;&lt;P&gt;Please help!&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Wed, 02 Oct 2024 21:27:46 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/how-to-control-numeric-format-using-arcpy/m-p/1544976#M88812</guid>
      <dc:creator>AntoinePrince1805</dc:creator>
      <dc:date>2024-10-02T21:27:46Z</dc:date>
    </item>
    <item>
      <title>Re: How to control numeric format using arcpy</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/how-to-control-numeric-format-using-arcpy/m-p/1545103#M88832</link>
      <description>&lt;P&gt;&lt;A href="https://community.esri.com/t5/python-questions/programmatically-format-numeric-fields-with-arcpy/td-p/285747" target="_blank"&gt;Solved: Programmatically format numeric fields with arcpy - Esri Community&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 03 Oct 2024 10:17:42 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/how-to-control-numeric-format-using-arcpy/m-p/1545103#M88832</guid>
      <dc:creator>MariusBartašius1</dc:creator>
      <dc:date>2024-10-03T10:17:42Z</dc:date>
    </item>
    <item>
      <title>Re: How to control numeric format using arcpy</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/how-to-control-numeric-format-using-arcpy/m-p/1545149#M88839</link>
      <description>&lt;P&gt;Thanks. That yet confirms that this does not seem possible unless I manually edit a layer file inside ArcGIS Pro, but I am looking for a python stand-alone solution.&lt;/P&gt;</description>
      <pubDate>Thu, 03 Oct 2024 12:56:35 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/how-to-control-numeric-format-using-arcpy/m-p/1545149#M88839</guid>
      <dc:creator>AntoinePrince1805</dc:creator>
      <dc:date>2024-10-03T12:56:35Z</dc:date>
    </item>
    <item>
      <title>Re: How to control numeric format using arcpy</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/how-to-control-numeric-format-using-arcpy/m-p/1545642#M88908</link>
      <description>&lt;P&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/699545"&gt;@AntoinePrince1805&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;One of the efficiencies of the CIM is also one of its limitations.&amp;nbsp; The CIM mostly persists non-default data to minimize its size and improve performance.&amp;nbsp; So if no alterations are made to default field info, the field info does not appear in the CIM definition.&lt;/P&gt;
&lt;P&gt;Try the code below.&amp;nbsp; The trick is to use MakeFeatureLayer which does include the CIM definitions, make alterations and copy the updated CIM information to your target layer.&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="python"&gt;p = arcpy.mp.ArcGISProject('current')
m = p.listMaps()[0]

lyr = m.listLayers('Provinces')[0]
lyr_cim = lyr.getDefinition('V3')

fList = ["SQKM", "POP2001", "Shape_Length", "Shape_Area"]

#IF NO CIM FIELD DESC INFO IS AVAILBLE
if len(lyr_cim.featureTable.fieldDescriptions) == 0:
    print('No CIM Field Info')
    
    #Make temporary layer (which automatically gets CIM field info)
    mkLyr = arcpy.management.MakeFeatureLayer(lyr)[0]
    mkLyr_cim = mkLyr.getDefinition('V3')
    for fd in mkLyr_cim.featureTable.fieldDescriptions:
        if fd.fieldName in fList:
            fd.numberFormat.roundingOption = "esriRoundNumberOfDecimals"
            fd.numberFormat.roundingValue = 0
            fd.numberFormat.zeroPad = True         
    mkLyr.setDefinition(mkLyr_cim)
    
    #Copy CIM information and remove temporary layer
    lyr_cim.featureTable.fieldDescriptions = mkLyr_cim.featureTable.fieldDescriptions  
    lyr.setDefinition(lyr_cim)
    m.removeLayer(mkLyr)&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;Jeff - arcpy.mp and Layout teams&lt;/P&gt;</description>
      <pubDate>Fri, 04 Oct 2024 15:35:44 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/how-to-control-numeric-format-using-arcpy/m-p/1545642#M88908</guid>
      <dc:creator>JeffBarrette</dc:creator>
      <dc:date>2024-10-04T15:35:44Z</dc:date>
    </item>
    <item>
      <title>Re: How to control numeric format using arcpy</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/how-to-control-numeric-format-using-arcpy/m-p/1545839#M88923</link>
      <description>&lt;P&gt;This answer has been deleted.&lt;/P&gt;</description>
      <pubDate>Fri, 04 Oct 2024 21:01:18 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/how-to-control-numeric-format-using-arcpy/m-p/1545839#M88923</guid>
      <dc:creator>AntoinePrince1805</dc:creator>
      <dc:date>2024-10-04T21:01:18Z</dc:date>
    </item>
    <item>
      <title>Re: How to control numeric format using arcpy</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/how-to-control-numeric-format-using-arcpy/m-p/1545842#M88924</link>
      <description>&lt;P&gt;This is it!!&lt;/P&gt;&lt;P&gt;Exactly what I was looking for. Although you made me work a bit late for a friday afternoon, I am still grateful.&lt;/P&gt;</description>
      <pubDate>Fri, 04 Oct 2024 21:01:33 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/how-to-control-numeric-format-using-arcpy/m-p/1545842#M88924</guid>
      <dc:creator>AntoinePrince1805</dc:creator>
      <dc:date>2024-10-04T21:01:33Z</dc:date>
    </item>
  </channel>
</rss>

