3

I have a problem with replacing in field calculator. For some reason my Python parser is not working. So I'm going to use VB and having tonns of this

Replace([field],"x","y") 
Replace([field],"z","a")
Replace([field],"1","2")
.
.
.
.
Replace([field],"g","j")

I would like to make all this into 1 line script. How to combine all of this?

  • I'm assuming that you are using the ArcGIS Field Calculator so I'm going to set tags for that. What do your current code block and expression look like? – PolyGeo May 22 '17 at 10:59
  • 1
    It's difficult to believe that Python stopped working, since ArcGIS geoprocessing would not function without it. Instead of soliciting help with a work-around, please Edit the question to address the root issue – Vince May 22 '17 at 11:02
  • reason is when i use this on python parser !field!.replace() it doesnt work and in the geoprocessing result: Error 000539: syntax error: EOL while scanning string literal (<expression>, line 1) BTW im not an expert just trying to translate characters with field calculator and thanks for your help – Rmn May 22 '17 at 11:10
  • Please use the edit button beneath your question to revise it with any requested clarifications. – PolyGeo May 22 '17 at 11:47
  • I wouldn't expect "!field!.replace" to work, but if you use the pre-script code block to define a function, "fixString (!field!)" should work fine. – Vince May 22 '17 at 13:34
0

Have you tried to embed function calls like this:

Replace(  Replace([field],"x","y"),  "z","a")

You should be able to apply functions to the results of other function calls as many times as you like.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.