Select to view content in your preferred language

CalculateField_management generates ERROR 000539 depending on values

4489
15
01-14-2018 10:26 PM
YasunariMorita
Emerging Contributor

Hi!

I tried copy values from COUNT attribute to test attribute.

(expression ="!COUNT!")

I used CalculateField_management, but CalculateField_management generates ERROR 000539 depending on values.

TEST1:I tried CalculateField using this table.

OIDValueCOUNTSUMtest
-165E+081.61E+09

I got the error below.

ExecuteError: ERROR 000539: <type 'exceptions.SyntaxError'>: unexpected EOF while parsing (<expression>, line 1)
Failed to execute (CalculateField).

TEST2:I tried CalculateField using this table whose value in COUNT attribute changed .

OIDValueCOUNTSUMtest
-165.1E+081.61E+09

This time, CalculateField worked well.

Why value"5.1E+08" worked well and did not work value"5E+08" ?

How should I avoid this problem?

my arcGIS version is 10.5

Thanks in advance.

0 Kudos
15 Replies
YasunariMorita
Emerging Contributor

Oh...sorry

I use "C:/Work01/scratch_00.gdb/tmp_table" and try again.

The result is ....

ERROR 000539: SyntaxError: unexpected EOF while parsing (<expression>, line 1)

same error...

I think this may not be the Unicode issue....

0 Kudos
DanPatterson_Retired
MVP Emeritus

Again, as I suggested before, go and do it manually for the one that worked and copy the python snippet from the results window... If that doesn't work and you  have the right field type and this doesn't work either, then I am out of ideas.

arcpy.CalculateField_management(in_table="C:/Work01/scratch_00.gdb/tmp_table",
                                field="test",
                                expression="!COUNT!",
                                expression_type="PYTHON_9.3)
# note... I dumped the code block which is optionaly anyway
# and I parsed them so they were readable
XanderBakker
Esri Esteemed Contributor

If, it the very unlikely situation that the snippet provided by Dan, does not work you could consider to forget about the field calculator and implement a cursor like this:

import arcpy

fc = r'C:\Work01\scratch_00.gdb\tmp_table'
fld_from = 'COUNT'
fld_to = 'test'

with arcpy.da.UpdateCursor(fc, (fld_from, fld_to)) as curs:
    for row in curs:
        row[1] = row[0]
        curs.updateRow(row)
YasunariMorita
Emerging Contributor

Thanks Dan and Xander

Sorry for my impolite > Dan

Xander's code worked well and the code below also worked ...

arcpy.CalculateField_management(in_table="C:/Work01/scratch_00.gdb/tmp_table",
    field="test",
    expression="[COUNT]",
    expression_type="VB")‍‍‍‍

But, only this code doesn't work. Of course, it works well for other tables.

(I done it manually for the one that worked(Only changed table name) and copied the python snippet from the results window.)

arcpy.CalculateField_management(in_table="C:/Work01/scratch_00.gdb/tmp_table",
 field="test",
 expression="!COUNT!",
 expression_type="PYTHON_9.3")‍‍‍‍‍‍‍‍‍‍‍‍

tmp_table:

OIDValueCOUNTSUMtest
-165E+081.61E+09

For example, this code works well (copied the python snippet from the results window).

arcpy.CalculateField_management(in_table="C:/Work01/scratch_00.gdb/tmp_table2",
 field="test",
 expression="!COUNT!",
 expression_type="PYTHON_9.3")‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

tmp_table2:

OIDValueCOUNTSUMtest
-165.1E+081.61E+09

Thanks again Dan and Xander

YasunariMorita
Emerging Contributor

I have reported this problem to ESRI Japan and sent data(tmp_table).

They confirmed that they reproduced this phenmenon in their environment.

0 Kudos
camilogarcia
New Contributor

hello there

lest try changing this 

expression="!COUNT!"

for this  "\!COUNT!\"

and

expression_type="PYTHON"

works for me 

 

0 Kudos