"""BGA ball grid renderer — for pin_loc.csv style files.""" import csv from html import escape def render(filepath): """Render CSV as BGA ball grid table.""" rows = [] with open(str(filepath), encoding='utf-8') as f: for row in csv.reader(f): rows.append([c.strip() for c in row]) if len(rows) < 2: return '

empty or malformed file

' ncols = len(rows[0]) - 1 h = [''] for c in range(1, ncols + 1): h.append(f'') h.append('') for r in rows[1:]: if not r: continue h.append( f'' ) for c in range(1, ncols + 1): val = r[c] if c < len(r) else '' h.append( f'' ) h.append('') h.append('
{c}
{escape(r[0])}{escape(val)}
') return '\n'.join(h)