def filled_int(val, length):
    """
    Takes a value and returns a zero padded representation of the integer component.

    :param val: The original value.
    :param length: Minimum length of the returned string
    :return: Zero-padded integer representation (if possible) of string. Original string used if integer conversion
    fails
    """
    try:
        converted_val = int(val)
    except ValueError:
        converted_val = val
    return str(converted_val).zfill(length)