import six


def format_stat(stat):
    """Turn numbers possibly with embedded commas into integers.

    Also accepts existing ints, which may be pre-converted from Excel.

    :param stat: numeric value, possibly with commas

    :return: int
    """
    if isinstance(stat, six.integer_types):
        return stat

    stat = stat.replace(',', '')
    stat = stat.lstrip('=')
    try:
        return int(stat)
    except ValueError:
        return None