def FindLabel(field,length): wlist = field.split(" ") linelist = [] scratch = [] chars = "" for w in wlist: if len(chars) <= length: chars += " ".join(["",w]) chars = chars.lstrip() if len(chars) > length: linelist.append(" ".join(i for i in chars.split(" ")[:-1])) chars = chars.split(" ")[-1] if len(chars) < length: pass elif len(chars) == length: linelist.append(chars) else: linelist.append(chars) else: scratch.append(chars) try: if scratch[-1] not in linelist: linelist.append(scratch[-1]) if wlist[-1] not in linelist: linelist.append(wlist[-1]) if linelist[-2].split(" ")[-1] == linelist[-1]: del linelist[-1] except: pass label = "\n".join(str(i) for i in linelist) return label if __name__ == '__main__': # Cut this out of label expression import arcpy dbf = r'C:\Testing\deed.dbf' with arcpy.da.SearchCursor(dbf,['DEEDHOLDER']) as rows: for row in rows: name = row[0] label = FindLabel(name,15) print label if label.replace("\n"," ") == name: print '\ntrue\n' else: print '\nfalse\n'
Angemeldete Mitglieder können Beiträge verfassen, Updates folgen und mehr. Neu hier? Registriere ein kostenloses Konto.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.