Field Calculator error on ObjectID = 0, which doesn't exist(?)

11704
12
Jump to solution
02-09-2016 08:04 AM
johnpolo
New Contributor III

I am adding a text/string field, "countyname", to a shapefile table. When I use Field Calculator to change the new fields to "Delaware", I get this error message

The calculated value is invalid for the row with ObjectID = 0. For example, the calculated value may be too large for the field or you may be trying to add a string to a number field. This row will not be updated. Do you want to process the rest of the rows?

It goes on with a warning about what happens if I say yes or no. I select Yes and the process fails. I don't know why this is happening or why it's referring to ObjectID = 0, when there is no such ObjectID. ObjectID starts with 1.

0 Kudos
12 Replies
DanPatterson_Retired
MVP Emeritus

or even export it to a new shapefile, I suspect that an index file has somehow been set out of sync.  I have seen this before, so either to a geodatabase or a shapefile will either fix it or identify errors.  Should the file be a poly* type, then try running a repair geometry to ensure that there are no geometry errors which might foul up the indices.

0 Kudos
johnpolo
New Contributor III

Actually, I missed something obvious: quotes. Thanks, Dan, for replying.

LukacsDavid
New Contributor

Yes.. The problem was the missing of the quotes: In case of adding a text/string field  to a shapefile table, you should write like this: 

arcpy.CalculateField_management("Layer_Name","Column_Name", '"String/text_you_want_to_add"')

0 Kudos