"""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' | {c} | ') h.append('
|---|---|
| {escape(r[0])} | ' ) for c in range(1, ncols + 1): val = r[c] if c < len(r) else '' h.append( f'{escape(val)} | ' ) h.append('