Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I'm writing a ModelBuilder to run many shapefiles output to database that has the sum acres for each crop however by looking at the field column it does not show comma like for example

Alfalfa 351178.314628 what I would like to make the number 351178.314628 into 351,178 ?

I can export it to python and add if there is code; however I am not python expert.

I'll have this screenshot sample:

Summary ModelBuilder

enter image description here

share|improve this question
    
I updated my answer below, since based on your other questions you definitely the comma automatically inserted. I hope it's more helpful now. –  Erica Jul 17 at 12:43

3 Answers 3

up vote 12 down vote accepted

Two approaches are possible, depending on what your goal is.

Display Purposes Only, Don't Want Extra Field

This isn't a function in ModelBuilder, but rather a question of how the number is being displayed in the attribute table. Here's how to change that (based on these instructions):

  1. Right-click on the field heading (SUM_Acres_) and choose "Properties"
  2. Click the ... button next to "Numeric"
  3. In the next window, check the "Show thousands separators" box.

(You can also reduce the number of decimal places it shows in the same dialog.)

The Data Needs That Comma, An Additional Field Is Fine

If you want this to be all contained within one ModelBuilder operation and/or done automatically for you, the table will need to have a new field. (This can simplify subsequent sharing, labeling, etc. since the previous method will only affect the attribute column display, not the underlying data.)

Two additional operations are required in the model for this:

additional ModelBuilder steps

  1. Add Field: Add a new field. Make sure that the new field type is TEXT.

    add field inputs

  2. Calculate Field: Use the expression format(int(!SUM_Acres_!), ",") in the field calculator: this will both remove trailing decimals, and include commas as thousands separators.

    ModelBuilder can be quirky about the fields it lists after an Add Field operation, so you might need to type in the name of the new field. Make sure that Expression Type is set to PYTHON not VB.

    calculate field inputs

share|improve this answer
    
I'm going to try this method Thanks ! –  PROBERT Jul 17 at 14:32
    
That is what I just need ! Thanks Erica.. –  PROBERT Jul 17 at 16:27
    
Glad it worked. Sorry I didn't fully understand what you were hoping to get the first time I answered :) –  Erica Jul 17 at 16:28
    
Sorry I tried my best. I'll show the the picture in a minute...I added what you suggest and then I tried and it works nicely ! –  PROBERT Jul 17 at 16:31

Alternatively, you can create a string field and calculate the following into it using python:

{:,}'.format(!SUM_Acres_!)
share|improve this answer
    
@gtein_appgeo How or where should I insert this in Python ? –  PROBERT Jul 15 at 20:34

I've made some modified and an additional tools to make this Model Builder a final one. I ran this on test and this works very nicely !! I would like to thank Erica for her help to make this possible My Model Builder

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.