Last active
January 2, 2016 03:29
-
-
Save cmc333333/8244055 to your computer and use it in GitHub Desktop.
Table widths
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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