def update_name(name, mapping): import re import zipcode_functions name = re.sub('(\.)|(,)','',name) name = re.findall(r'(\S+)',name) additional_address = '' for i in range(0,len(name)): m = re.search(r'^([a-z]|_)*$', name[i]) if m: name[i] = name[i].title() del m if i > 0: m = re.search('Unit$|Suite$|Building$',name[i-1]) if m: name, additional_address = get_suite(name,i) break else: pass try: name[i] = mapping[name[i]] except: pass name = remove_city_state(name,'Colorado') new = zipcode_functions.reassemble_name(name) return new, additional_address
def get_suite(name,i): import zipcode_functions name[i] = name[i].upper() additional_address = zipcode_functions.reassemble_name(name[i-1:i+1]) name = name[:i-1] + name[i+1:] return name, additional_address