Convert a text field to a numeric field

7536
7
Jump to solution
01-26-2022 07:25 AM
mkhenson
New Contributor III

I have a shape file that was exported from Autocad Map.  It represents pipes in a network.  I have a field representing the pipe dia, but it is a text field and would like to convert it to numeric.  Can someone walk me thru those steps?  Name of the text field is "LAYER" and I need the new numeric one to be "DIA"  Thanks for any help you can give.

MKH

0 Kudos
3 Solutions

Accepted Solutions
JayantaPoddar
MVP Esteemed Contributor

As mentioned by Sean, you need to add a field "DIA" with Type LONG INTEGER or FLOAT, depending on whether the desired value is an integer or Decimal Point value respectively.

Then Right-click "DIA" field > Field Calculator.

Expression:

[LAYER]

JayantaPoddar_0-1643214044756.png

 

 



Think Location

View solution in original post

AdrianWelsh
MVP Honored Contributor

The first thing you need to do is Add a Field and make sure you make it numeric. If you just need integers (whole numbers), choose Long as the data type. If you need a floating point decimal, choose Double as the data type:

AdrianWelsh_0-1643214155187.png

 

Now that you have this new field, DIA, right click on it and choose "Calculate Field":

AdrianWelsh_1-1643214236709.png

 

If you need to convert to an integer, in the field calculation box type this: 

int(!LAYER!)

If it's a floating point, type this:

float(!LAYER!)

 Make sure Python 3 is chosen as your Expression Type:

AdrianWelsh_2-1643214387304.png

 

View solution in original post

Sean_Wray
Occasional Contributor

Yes - my apologies for the rushed answer...

In ArcMap open your table. On the drop down choose Add Field.

Sean_Wray_1-1643220989344.png

Name it - define it as double

Sean_Wray_2-1643221204029.png

The right click the new field name in the table and choose Field Calculator

Sean_Wray_3-1643221327344.png

A box will popup. The field you are calculating will be populated. See in the screenshot where it says TEST=. Then in the fields box, double click the field name you want to copy the data from. In the example I choose X and click OK

Sean_Wray_4-1643221511801.png

 

View solution in original post

0 Kudos
7 Replies
Sean_Wray
Occasional Contributor

You can use the add field tool and then use the field calculator to calculate what goes in it.

https://desktop.arcgis.com/en/arcmap/10.3/tools/data-management-toolbox/add-field.htm

mkhenson
New Contributor III

yeah, I've seen the help, but it reads like a programming language, which confuses me entirely!

 

0 Kudos
AdrianWelsh
MVP Honored Contributor

The first thing you need to do is Add a Field and make sure you make it numeric. If you just need integers (whole numbers), choose Long as the data type. If you need a floating point decimal, choose Double as the data type:

AdrianWelsh_0-1643214155187.png

 

Now that you have this new field, DIA, right click on it and choose "Calculate Field":

AdrianWelsh_1-1643214236709.png

 

If you need to convert to an integer, in the field calculation box type this: 

int(!LAYER!)

If it's a floating point, type this:

float(!LAYER!)

 Make sure Python 3 is chosen as your Expression Type:

AdrianWelsh_2-1643214387304.png

 

JayantaPoddar
MVP Esteemed Contributor

As mentioned by Sean, you need to add a field "DIA" with Type LONG INTEGER or FLOAT, depending on whether the desired value is an integer or Decimal Point value respectively.

Then Right-click "DIA" field > Field Calculator.

Expression:

[LAYER]

JayantaPoddar_0-1643214044756.png

 

 



Think Location
mkhenson
New Contributor III

Thanks very much.  I appreciate the replies!  

0 Kudos
Sean_Wray
Occasional Contributor

Yes - my apologies for the rushed answer...

In ArcMap open your table. On the drop down choose Add Field.

Sean_Wray_1-1643220989344.png

Name it - define it as double

Sean_Wray_2-1643221204029.png

The right click the new field name in the table and choose Field Calculator

Sean_Wray_3-1643221327344.png

A box will popup. The field you are calculating will be populated. See in the screenshot where it says TEST=. Then in the fields box, double click the field name you want to copy the data from. In the example I choose X and click OK

Sean_Wray_4-1643221511801.png

 

0 Kudos
mkhenson
New Contributor III

Thanks Sean...that's perfect!  I appreciate it very much