Skip to content

Instantly share code, notes, and snippets.

@cmc333333
Last active January 2, 2016 03:29
Show Gist options
  • Select an option

  • Save cmc333333/8244055 to your computer and use it in GitHub Desktop.

Select an option

Save cmc333333/8244055 to your computer and use it in GitHub Desktop.
Table widths
max_width = 0
for header_row in table['header']:
width = sum(cell['colspan'] for cell in header_row)
max_width = max(max_width, width)
# Just in case a row is longer than the header
row_max = max(len(row) for row in table['rows'])
max_width = max(max_width, row_max)
# Now pad rows if needed
for row in table['rows']:
row.extend([''] * (max_width - len(row)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment