import sys,collections,math sys.stdout.reconfigure(encoding='utf-8') by=collections.defaultdict(list); segs={}; cur=None for l in open('pcol.txt',encoding='utf-8'): if l.startswith(' seg'): segs.setdefault(cur,[]).append(l.strip()); continue if ' | len ' not in l: continue p=l.strip().split(' | '); nm=p[0]; k=nm.split('-')[2]; cur=k d={'nm':nm,'len':float(p[1].split()[1]),'mn':eval(p[2].split('min ')[1]),'mx':eval(p[3].split('max ')[1])} for q in p[4:]: kk,_,vv=q.partition(' '); d[kk]=vv by[k].append(d) for k in sorted(by): v=by[k]; f=v[0] zs=sorted({round(r['mn'][2],1) for r in v}); zt=sorted({round(r['mx'][2],1) for r in v}) print('====',k,'n',len(v),'dia',f.get('dia'),'shape',f.get('shape'),'design',sorted({float(r['dl']) for r in v})[:4],'coupler',sorted({r.get('cl') for r in v})[:3],'sum %.3f'%(sum(float(r['dl']) for r in v)/1000)) print(' example',f['nm'],'| host',f.get('host'),'| anchor',f.get('anchor'),'| src:',(f.get('src') or '')[:160]) print(' Z min',zs[:6],'..',zs[-3:],'n',len(zs),' Z max',zt[:4],'..',zt[-3:]) print(' X',round(min(r['mn'][0] for r in v)),round(max(r['mx'][0] for r in v)),'Y',round(min(r['mn'][1] for r in v)),round(max(r['mx'][1] for r in v))) for s in segs.get(k,[])[:7]: print(' ',s)