Convert String to Double

38197
14
Jump to solution
05-22-2012 11:22 AM
TimHayes
Occasional Contributor III
In a Feature Class Attribute Table, I have data in a column that is of string data type and need to convert it to a double data type. I have already added an empty column with a double data type on which I can use the Field Calculator.

What is the best way to go about this?
14 Replies
MichaelRobb
Occasional Contributor III

It should work fine if the featurelcass is in a FileGeodatabase. A Shapefile will not work for what you are looking for as I have mentioned.

Id Import the shapefile into a FileGeodatabase and then your desired <null> will work... and so would the script.

GoldenJiang
New Contributor II

What's the difference if I save a featureclass in a folder or save it in a FileGeodatabase?

I have been saving data to folders all the time. Hope that doesn't affect my yield data. 

0 Kudos
curtvprice
MVP Esteemed Contributor

What's the difference if I save a featureclass in a folder or save it in a FileGeodatabase?

I have been saving data to folders all the time. Hope that doesn't affect my yield data.

Datasets saved to a folder from ArcGIS tool output are saved in shapefile (feature classes) and .dbf table format.

Geoprocessing considerations for shapefile output—Help | ArcGIS Desktop 

Geoprocessing considerations for shapefile output—Appendices | ArcGIS Desktop   (Pro)

0 Kudos
MichaelRobb2
New Contributor II

Well this is weird.  For a minute I thought I had forgotten how to code in the last 7 years, but quickly realised that my name sake had just helped me out, thanks!!

0 Kudos
MichaelRobb
Occasional Contributor III

Alternatively, you can use the "Show Codeblock" in the field calculator and then use

Output = CDbl( [lFIELDNAME])

[Field] = Output

CDbl converts the string to double.

You can then add more items such as Replace as well to remove items such as periods or decimals if need be

e.g.

Output = CDbl( Replace([FIELDNAME],"."," "))