I'm trying to use the Field Calculator (ArcMap 10.0) to strip out double quotes in an address field (I didn't put them in there, believe me). I've tried many incantations but am still unable to even get off the ground with a calculation. yes, both fields are string, and both are of acceptable length.
This calculation:
Results in this:
With this error message in the Results dialog:
And I repeat, I didn't put them in there.
Best Answer
I have found that in 10.0 Field Calculator is quite weird.
But I've managed to get it work. The main idea is to enclose field name with single quotes.
Example. let suppose we have fields
text1
andtext2
. Rather than Calculating fieldtext2
with expression!text1!
, which probably will fail, try this one:'!text1'
. As you see I am using single quotes here.So, back to your task. It will be more clear to use Pre-Logic Script Code:
Expression will be:
I hope it will work for you.
I have not experimented further but I think that such weird behavior happens because field calculation is translated into the call to ArcToolbox tool
CalculateField_management
and expression is provided as a parameter to it (probably additionally enclosed with single or double quotes).UPDATE:
My previous solution will fail in case if there are single quotes in the values of field
text1
.Now I have managed to get it work both in case when there are chars
'
and"
(single and double quotes) inside any value in attributetext1
.Here is expression, which will return original string, supporting both types of quotes:
For your task it can be extended to (without Pre-Logic Script Code):