Hello. I am using the field calculator to multiply the value in the field "flash_area" by 0.15. I have attached a couple screenshots.
It works for about half of the entries but then it stops and I get error 000539 syntax error: invalid syntax. My field newArea is a float. I am using ArcMap 10.6.
Solved! Go to Solution.
Look at the values in flash_area; if it does some but not all, it's hitting a record with a value it can't handle. Check for <null> values. Something about object id 3139 is goofing on you. Create a copy and delete that record and run your calculation on the copy and see if / where it bails out. I just ran the value in a Spyder console and I got a return:
flasharea = 1000000000
x = flasharea*.15
x
'''150000000.0
What is the data type on flash_area? Your script does not like the value 1000000000 in the first row with a NULL.
That is also a float. Thanks.
Look at the values in flash_area; if it does some but not all, it's hitting a record with a value it can't handle. Check for <null> values. Something about object id 3139 is goofing on you. Create a copy and delete that record and run your calculation on the copy and see if / where it bails out. I just ran the value in a Spyder console and I got a return:
flasharea = 1000000000
x = flasharea*.15
x
'''150000000.0
I made a copy and deleted that record. It worked after that.
I'm not really sure what was wrong with that record. I eventually want to create a script that will process this data. Each day I will have a new file with new data.
Yes, for repetitive tasks, a script is the way to go. You may want to 'wrap' the calculation is a try/except block so you can gracefully exit out of it if there's an error. Calculate or update cursor would do the trick.
I brought this up to Esri and they said it's actually a bug with certain numbers (like 1000000000). I will try a workaround with the try/except block. Thanks.
BUG-000110899
Synopsis: Populating the field using Python expression for a specific value returns an error in the field calculator.
A bug with 'certain numbers'? Since 1990 or so I've been using ESRI products and just when I thought I'd heard it all.
Is there any chance they may fix that little problem?
You might be better off using an update cursor if calculating is problematic (at least for certain numbers, that just slays me...).
I'm not sure if they will fix it soon. It is listed as "Medium" under "Severity." Apparently this has been a bug since version 10.5.