Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

i'm traying to implent python string translate function at field calculatore http://www.tutorialspoint.com/python/string_translate.htm in order to fix hebrew imported from cad. here is the code -

def Ttxt (RefName):
  from string import maketrans   
  intab = "asdfghjkl"
  outtab = "שדגכעיחלך"
  return trantab = maketrans(intab, outtab)

Ttxt( !RefName! )

Any sugestion about how to right this function ?

share|improve this question
1  
What kind of software do you use? It is not obvious from question what is field calculator. –  drnextgis Jul 17 '12 at 8:21
add comment

1 Answer

Judging from the examples on the site you would need something like this (untested):

def Ttxt (RefName):
  from string import maketrans   
  intab = "שדגכעיחלך"
  outtab = "asdfghjkl"
  trantab = maketrans(intab, outtab)

  return RefName.translate(trantab)
share|improve this answer
    
now i get this error messege: 000539 'return' outside function (<string>, line 6) –  Alex Jul 17 '12 at 10:17
    
You haven't got your function formatted correctly –  Nathan W Jul 17 '12 at 10:35
    
def Ttxt (RefName): import string from string import maketrans intab = "asdfghjkl" outtab = "שדגכעיחלך" transtab = string.maketrans(intab, outtab) return RefName.translate(transtab) and now 000989 unexspected indent (line 4) –  Alex Jul 17 '12 at 10:59
1  
posting Python in the comments isn't going to help because Python uses white space to work out code blocks. Maybe read up on a bit of Python first. –  Nathan W Jul 17 '12 at 11:09
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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