bhorat

Error 539 while running CalculateField to copy strings

Discussion created by bhorat on Jul 31, 2012
Latest reply on Aug 3, 2012 by bhorat
Hi,

I'm trying to copy all information from one string field to a new one in the same feature class. I am using this code:

#Feature class:
Tab = r'\\Tako\gis\03_basisdaten\pronatura\ch\gisdata\pronatura_1.gdb\Schutzgebiete\parz_pn'
#Field:
orgField = "Bemerkungen"
#Length of Field:
Length = 1000


#Adding the new Field:
provField = orgField + "_prov"
AddField_management(Tab,provField,"TEXT", "", "", Length)

#Copy the information from the original field to the new one:
Expression = 'str(!%s!)' %(orgField)
CalculateField_management(Tab, provField, Expression, 'PYTHON')


The tool stops at feature 52 of 2500 and gives this Error:

Runtime error <class 'arcgisscripting.ExecuteError'>: ERROR 000539: Error running expression: str("1x jährlich im Herbst zu mühen. Er verwendet Flurname "Hiwes", vormals Parz. 200310  ") <type 'exceptions.SyntaxError'>: invalid syntax (<string>, line 1) Failed to execute (CalculateField).


I assume there is some problem with the " in the string to copy. How can I tell Python to treat the string as one and ignore all special characters?

Outcomes