<commit_before>def rpad(s,l,pad_string=' '):
    return s + (pad_string * (l - len(s)))

def asciitable(dicts,disp_cols=None,none_msg=None):
    """produce an ASCII formatted columnar table from the dicts"""
    dicts = list(dicts)
    if not dicts:
        if none_msg is not None:
            yield none_msg
        return
    # set of all keys in dicts
    cols = sorted(list(set(reduce(lambda x,y: x+y, [d.keys() for d in dicts]))))
    if disp_cols is not None:
        cols = disp_cols
    # compute col widths. initially wide enough for the column label
    widths = dict([(col,len(col)) for col in cols])
    # now create rows, and in doing so compute max width of each column
    for row in dicts:
        for col in cols:
            try:
                width = len(str(row[col]))
            except KeyError:
                width = 0
            if width > widths[col]:
                widths[col] = width
    # now print rows
    yield ' | '.join([rpad(col,widths[col]) for col in cols])
    yield '-+-'.join(['-' * widths[col] for col in cols])
    for row in dicts:
        yield ' | '.join([rpad(str(row[col]),widths[col]) for col in cols])<commit_msg>snazzier version of asciitable with border<commit_after>def rpad(s,l,pad_string=' '):
    return s + (pad_string * (l - len(s)))

def asciitable(dicts,disp_cols=None,none_msg=None,border=True):
    """produce an ASCII formatted columnar table from the dicts"""
    dicts = list(dicts)
    if not dicts:
        if none_msg is not None:
            yield none_msg
        return
    if disp_cols is not None:
        cols = disp_cols
    else:
        # set of all keys in dicts
        cols = sorted(list(set(reduce(lambda x,y: x+y, [d.keys() for d in dicts]))))
    # compute col widths. initially wide enough for the column label
    widths = dict([(col,len(col)) for col in cols])
    # now create rows, and in doing so compute max width of each column
    for row in list(dicts):
        for col in cols:
            try:
                width = len(str(row[col]))
            except KeyError:
                width = 0
            if width > widths[col]:
                widths[col] = width
    def bord(line,border_char='|',pad_char=' '):
        if border:
            return border_char + pad_char + line + pad_char + border_char
        else:
            return line
    # now print rows
    spacer = bord('-+-'.join(['-' * widths[col] for col in cols]),'+','-')
    if border:
        yield spacer
    yield bord(' | '.join([rpad(col,widths[col]) for col in cols]),'|')
    yield spacer
    for row in dicts:
        yield bord(' | '.join([rpad(str(row[col]),widths[col]) for col in cols]),'|')
    if border:
        yield spacer
{'fraction_non_alphanumeric': 0.12107788851974899, 'fraction_numerical': 0.0007382798080472499, 'mean_word_length': 2.2689987937273823, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6752125', 'n_tokens_mistral': 881, 'n_tokens_neox': 855, 'n_words': 286}