Created
July 6, 2012 07:42
-
-
Save thanhleviet/3058735 to your computer and use it in GitHub Desktop.
Field calculator to search and replace string field.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def SearchAndReplace(field): | |
global giatri | |
if field.find("Huyện") <> -1: | |
giatri= field.replace("Huyện","H.") | |
elif field.find("Huyên") <> -1: | |
giatri =field.replace("Huyên","H.") | |
elif field.find("Thị Xã") <> -1: | |
giatri= field.replace("Thị Xã","TX.") | |
elif field.find("Thị xã") <> -1: | |
giatri= field.replace("Thị xã","TX.") | |
elif field.find("Thị Trấn") <> -1: | |
giatri= field.replace("Thị trấn","TT.") | |
elif field.find("Thành Phố") <> -1: | |
giatri= field.replace("Thành Phố","TP.") | |
elif field.find("Thành phố") <> -1: | |
giatri= field.replace("Thành phố","TP.") | |
elif field.find("Quận") <> -1: | |
giatri= field.replace("Quận","Q.") | |
else: | |
giatri = field | |
return giatri |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment