Select to view content in your preferred language

Field Calculator produces Error 000539

4343
8
Jump to solution
07-16-2019 12:00 PM
AndrewL
Frequent Contributor

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.

0 Kudos
1 Solution

Accepted Solutions
JoeBorgione
MVP Emeritus

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
That should just about do it....

View solution in original post

8 Replies
LanceCole
MVP Regular Contributor

Andrew,

What is the data type on flash_area?  Your script does not like the value 1000000000 in the first row with a NULL.

 

0 Kudos
AndrewL
Frequent Contributor

That is also a float. Thanks.

0 Kudos
JoeBorgione
MVP Emeritus

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
That should just about do it....
AndrewL
Frequent Contributor

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.

0 Kudos
JoeBorgione
MVP Emeritus

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.

That should just about do it....
AndrewL
Frequent Contributor

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.

JoeBorgione
MVP Emeritus

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...).  

That should just about do it....
0 Kudos
AndrewL
Frequent Contributor

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.

0 Kudos