def format_col_infos(infos, color_dict, maxlength):
    """
    Format the infos passed as parameter so that they are displayed in a nice fashion in the console.
    :param infos: List or tuple of ColumnInfos instances. One per row.
    :param color_dict: Dictionary to set a color for each type of data.
    :param maxlength: Length of the longest name string. Need so each column of info is aligned.
    :return: A list of formatted strings to be joined with a line-return then to be displayed as is.
    """
    ret = []
    for i in range(len(infos)):
        colinfo = infos[i]
        ret.append(str(i) + ":\t\"" + colinfo.name + "\"" + "." * (
                maxlength + 2 - len(colinfo.name)) + "of type %s \t%s null values and %d uniques%s." % (
                       "\x1b[" + color_dict[str(colinfo.dtype)] + "m" + str(colinfo.dtype) + "\x1b[0m",
                       str(colinfo.n_rows), colinfo.uniques,
                       "" if not colinfo.categories else " [" + ", ".join(map(str, colinfo.categories)) + "]"))
    return ret