def format_table(table, extra_space=1):
    """
    Note: `evennia.utils.evtable` is more powerful than this, but this
    function can be useful when the number of columns and rows are
    unknown and must be calculated on the fly.

    Args.
        table (list): A list of lists to represent columns in the
            table: `[[val,val,val,...], [val,val,val,...], ...]`, where
            each val will be placed on a separate row in the
            column. All columns must have the same number of rows (some
            positions may be empty though).
        extra_space (int, optional): Sets how much *minimum* extra
            padding (in characters) should  be left between columns.

    Returns:
        table (list): A list of lists representing the rows to print
            out one by one.

    Notes:
        The function formats the columns to be as wide as the widest member
        of each column.

    Examples:

        ```python
        ftable = format_table([[...], [...], ...])
        for ir, row in enumarate(ftable):
            if ir == 0:
                # make first row white
                string += "\n|w" + ""join(row) + "|n"
            else:
                string += "\n" + "".join(row)
        print string
    ```
    """
    if not table:
        return [[]]

    max_widths = [max([len(str(val)) for val in col]) for col in table]
    ftable = []
    for irow in range(len(table[0])):
        ftable.append([str(col[irow]).ljust(max_widths[icol]) + " " * extra_space
                       for icol, col in enumerate(table)])
    return ftable