def fulladdress(num, prefix, street, sttype, suffix, unit): # Concatenate fields # for addresses without unit if unit: fulladd = num +' '+ prefix+' '+street+' '+sttype+' '+suffix+' #'+unit # for addresses with unit else: fulladd = num +' '+ prefix+' '+street+' '+sttype+' '+suffix # Remove unwanted spaces fulladd = fulladd.strip() fulladd = fulladd.replace(' ',' ') return fulladd
def fulladd(num, prefix, street, sttype, suffix, unit):
add = [num,prefix,street,sttype,suffix,''.join(["#",unit.strip()])]
fulladd = ''.join([''.join([a.strip()," "]) for a in add if a.strip() not in ['#None','','#']]).strip()
return fulladd
Ok, I promise this will be the last revision 😄 I tend to obsess about these things sometimes. Also, you might be able to change the little exclude list from ['#None','','#'] to ['','#']...... I'm not entirely sure of what a null value will return in this context (i.e. 'None' vs. '' vs. ' '). You should mess around with it. Cheers to working with structure data!def fulladd(num, prefix, street, sttype, suffix, unit): add = [num,prefix,street,sttype,suffix,''.join(["#",unit.strip()])] fulladd = ''.join([''.join([a.strip()," "]) for a in add if a.strip() not in ['#None','','#']]).strip() return fulladd
def fulladd(num,prefix,street,sttype,suffix,unit): add = [num,prefix,street,sttype,suffix,''.join(['#',unit])] fulladd = ''.join([''.join([a.strip()," "]) for a in add if a.strip() not in ['','#']]).strip() return fulladd
fulladdress(str(!AddNum!), str(!Prefix!) , str(!Street!) , str(!Type!) , str(!Suffix!) , str(!Unit!))
def fulladd(num,prefix,street,sttype,suffix,unit):
fulladd = ''.join([''.join([a.strip()," "]) for a in [num,prefix,street,sttype,suffix,''.join(['#',unit])] if a.strip() not in ['','#']]).strip()
return fulladd
fulladdress(str(!AddNum!), str(!Prefix!) , str(!Street!) , str(!Type!) , str(!Suffix!) , str(!Unit!)).
def fulladd(num,prefix,street,sttype,suffix,unit): fulladd = ''.join([''.join([a.strip()," "]) for a in [num,prefix,street,sttype,suffix,''.join(['#',unit.strip()])] if a.strip() not in ['','#']]).strip() return fulladd