1

I have a float field which I want to simply update all values with 1. I can easily do this within the field calculator but I have started using python today, what is the syntax to simply update a field with the value 1. I'm stuck on the expression bit of the script:

arcpy.CalculateField_management("ROCHDALE_TEST_NET","FRMEAS",??????

1 Answer 1

3

Looking at the ArcGIS help section, you can see the necessary parameters and descriptions:

CalculateField_management (in_table, field, expression, {expression_type}, {code_block})

To translate this to your script;

import arcpy

file = r'C:\your\file.shp'

arcpy.CalculateField_management (file, "FRMEAS", "1")
3
  • Thanks, I was thinking into it to much by doing =1 or "!FRMEAS! = 1"
    – Alan Carr
    Apr 3, 2014 at 16:10
  • @Aaron if it's a float field, do you have to put the 1 in quotes?
    – ianbroad
    Apr 3, 2014 at 16:12
  • 1
    It is optional @ian
    – Aaron
    Apr 3, 2014 at 16:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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