Select to view content in your preferred language

Python Proper Case issues

771
2
02-10-2012 10:33 AM
DennisGookin
Deactivated User
In ArcMap 10.0 I am trying to convert all upper case street names to proper case.  I have the script which is   !ST_NAME!.title()  and it works fine for most streets.  However, on streets that have an apostrophe it will change it from HOLLY'S ST  to Holly'S St  with the letter after the apostrophe still capitalized.  Also, when I have a street like  46TH AVE  it will change it to 46Th Ave  leaving the letter after the number capitalized.  Is there a way to fix these?

Any help is appreciated
Tags (2)
0 Kudos
2 Replies
BruceNielsen
Frequent Contributor
Try this:
" ".join([x.capitalize() for x in !ST_NAME!.split(" ")])
0 Kudos
RichardFairhurst
MVP Alum
Don't forget the Scots!  MCDONALD will become Mcdonald, but should be McDonald.  MACRAY will become Macray, but should be MacRay.  We Scots just like to mess things up for you.  (But you have to give a pass on MACARONI to Macaroni, since were not Italian).  Of course the Irish half of me won't let you bypass all of the apostrophes, since O'HARE should become O'Hare.  Just a reminder that we are proud to be a Son of ... a Donald, Ray or Hare (or whatever else we are a Son of).
0 Kudos