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.
OID | Value | COUNT | SUM | test |
-1 | 6 | 5E+08 | 1.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 .
OID | Value | COUNT | SUM | test |
-1 | 6 | 5.1E+08 | 1.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.
Could you attach the whole python script? Ensure there is no indentation error.
Hi Jayanta,
Here is my script. In addition, I got the same error when using ArcMap toolbox.
# Replace a layer/table view name with a path to a dataset (which can be a layer file) or create the layer/table view within the script
# The following inputs are layers or table views: "tmp_table"
arcpy.CalculateField_management(in_table="tmp_table", field="test", expression="!COUNT!", expression_type="PYTHON_9.3", code_block="")
What happens if you replace "tmp_table" with the full path of the Feature Class?
Do it manually using the tool as per usual, then go to the 'Results' window and copy the python expression to get the correct syntax. That will solve the debate as to whether full paths or something in your expression is the issue.
Also check the definition of both fields. If they do not have the same numeric definition, you may run into problem of trying to fit a value into a reduced range of allowed values. I assume both fields are numeric, right?
Sorry for my poor info.
tmp_table:table class
tmp_table:C:\Work01\scratch_00.gdb\tmp_table
COUNT:Float
test:Float
original
メッセージ
実行: CalculateField tmp_table test !COUNT! PYTHON_9.3 #
開始時間: Mon Jan 15 15:01:42 2018
ERROR 000539: SyntaxError: unexpected EOF while parsing (<expression>, line 1)
(CalculateField) を実行できませんでした。
失敗 (Mon Jan 15 15:01:42 2018) (経過時間: 0.01 秒)
translation
message
execute: CalculateField tmp_table test !COUNT! PYTHON_9.3 #
start: Mon Jan 15 15:01:42 2018
ERROR 000539: SyntaxError: unexpected EOF while parsing (<expression>, line 1)
Failed to execute(CalculateField)
Failure (Mon Jan 15 15:01:42 2018) (elapsed time: 0.01 sec)
I checked two scripts below,but I got the same error.
arcpy.env.workspace = ur"C:\Work01\scratch_00.gdb"
arcpy.CalculateField_management(in_table="tmp_table", field="test", expression="!COUNT!", expression_type="PYTHON_9.3", code_block="")
arcpy.CalculateField_management(in_table="C:\\Work01\\scratch_00.gdb\\tmp_table", field="test", expression="!COUNT!", expression_type="PYTHON_9.3", code_block="")
ur as a prefix fails on my system
try just u or "C:/Work01/scratch_00.gdb"
since I assume you have a Unicode issue
Thanks Dan
I tried again according to your advice.
1
arcpy.CalculateField_management(in_table=u"C:\Work01\scratch_00.gdb\tmp_table", field="test", expression="!COUNT!", expression_type="PYTHON_9.3", code_block="")
I got parameter error.This is due to prefix of path(ur).
Runtime error
Traceback (most recent call last): File "<string>", line 1, in <module>
File "c:\program files (x86)\arcgis\desktop10.5\arcpy\arcpy\management.py", line 3663, in CalculateField
raise e ExecuteError: 実行できません。パラメーターが不正です。
ERROR 000732: 入力テーブル: データセット C:\Work01\scratch_00.gdb mp_table が存在しないか、サポートされていません
(CalculateField) を実行できませんでした。
2
arcpy.CalculateField_management(in_table=ur"C:\Work01\scratch_00.gdb\tmp_table", field="test", expression="!COUNT!", expression_type="PYTHON_9.3", code_block="")
I got the same error.
Runtime error
Traceback (most recent call last):
File "<string>", line 1, in <module> File "c:\program files (x86)\arcgis\desktop10.5\arcpy\arcpy\management.py", line 3663, in CalculateField
raise e ExecuteError:
ERROR 000539: SyntaxError: unexpected EOF while parsing (<expression>, line 1)(CalculateField) を実行できませんでした。
I think this may not be the Unicode issue....
you didn't try both... use this
"C:/Work01/scratch_00.gdb/tmp_table"
Note that the straight Unicode incarnation doesn't work either... so it is either 'r' (not 'u') or skip fiddling with windows notation and go straight to the forward slashes
'C: \\ Work01 \\ scratch_00.gdb \ tmp_table' note... \\ folder \\ gdb then a single \