<commit_before>#! /usr/bin/python3

def keyval(table, func=None):
    out = {}
    for row in table:
        if func is not None:
            out[func(row[0])] = func(row[1])
        else:
            out[row[0]] = row[1]
    return out<commit_msg>keyval allows for zero to two functions now.<commit_after>#! /usr/bin/python3

def keyval(sheet, *funcs):
    '''For a sheet with rows of keys and values, creates a dictionary from it with functions applied to the keys or keys and values, or none.
    Example: keyval(sheet, str, int)
    If only one function is provided, it will apply the function to keys and values.'''
    out = {}
    if not funcs:
        for row in sheet:
            out[row[0]] = row[1]
    else:
        print('hi')
        for row in sheet:
            if len(funcs) == 1:
                out[funcs[0](row[0])] = funcs[0](row[1])
            else:
                out[funcs[0](row[0])] = funcs[1](row[1])
    return out
{'fraction_non_alphanumeric': 0.12804232804232804, 'fraction_numerical': 0.01798941798941799, 'mean_word_length': 2.185185185185185, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '29761', 'n_tokens_mistral': 310, 'n_tokens_neox': 306, 'n_words': 104}