GIS tutorial for Python Scripting written by David Allen

3568
12
09-17-2014 06:05 PM
Jeremiah_OlatundeGbolagun
New Contributor

Please let me know if the below code is right or not. if it is wrong can you please correct it for me.

I changed the below code from the above titled book during learning Tutorial 1, which was titled "Use Python in the Label Expression dialog box". I am using ArcGIS 10.1 but the tutorial used ArcGIS 10.2.

This is the original code from the text book.

def FindLabel ( [OwnerName] 😞

  rawName = [OwnerName]

  commaNum = rawName.find(",")

  formatName = rawName[commaNum+2:] + " " + rawName[:commaNum]

  return formatName

When I run this above code I have this error "SyntaxError: invalid syntax (<string> , line 4"

Can you please let me know the right code to use.

I modify it to below code but still experience another error.

def FindLabel ( [OwnerName] 😞

  rawName = [OwnerName]

  commaNum = rawName.find(",")

  formatName = rawName(commaNum[2:]) + " " + rawName(commaNum[0:]

  return formatName

Regards,

Jeremiah.

0 Kudos
12 Replies
JaredStewart
New Contributor II

Hi Curtis,

Clicking on your blog link directs me to a page with the following message:

Access to this place or content is restricted. If you think this is a mistake, please contact your administrator or the person who directed you here.

0 Kudos
curtvprice
MVP Esteemed Contributor

Thanks for letting me know...  I moved my blog out of the python space to my personal space. It should be accessible by everyone now. 

0 Kudos
JaredStewart
New Contributor II

Excellent, thank you! That is a very handy tip!

0 Kudos