0

I have a field in GIS that it needs a precision and scale argument. Using Arcpy, I pass the argument like this:

d_fields = ["acres" , "p_dev"]  
    for field in d_fields:
        arcpy.AddField_management('SE_for_DC.dbf', "temp","DOUBLE", 15,6 )
        arcpy.CalculateField_management('SE_for_DC.dbf',"temp","!{}!".format(field), "PYTHON_9.3")
        arcpy.DeleteField_management('SE_for_DC.dbf', field)
        arcpy.AddField_management('SE_for_DC.dbf', field,"DOUBLE", 15,6 )
        arcpy.CalculateField_management('SE_for_DC.dbf',field,"!temp!", "PYTHON_9.3")   
        arcpy.DeleteField_management('SE_for_DC.dbf', "temp")

in where I create a temp field with the precision and scale parameters then copy the attribute over, then I recreate the new field with the right parameters and copy the data to it.

Whenever I open the dbf, both the precision and the scale fields have 0 values. How can I fix this error and why is it behaving like it?

  • 1
    dBase has two internal storage formats for floating-point values. The format used by ArcGIS doesn't store precision and scale metadata, so there isn't any way to retain this information. – Vince Oct 25 '18 at 17:38
  • @Vince is there a solution to this, can i use another python module or anything else? – Daniel Oct 25 '18 at 17:41
  • 1
    Possibly, but you'd need to Edit the question to focus on using the other Python module (having chosen one, and made an attempt to mirror the ArcPy code). If you don't use dBase, then most other representations permit precision and scale. – Vince Oct 25 '18 at 18:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.