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",??????

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")
  • Thanks, I was thinking into it to much by doing =1 or "!FRMEAS! = 1" – Alan Carr Apr 3 '14 at 16:10
  • @Aaron if it's a float field, do you have to put the 1 in quotes? – ianbroad Apr 3 '14 at 16:12
  • 1
    It is optional @ian – Aaron Apr 3 '14 at 16:16

Your Answer

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

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