def convert_km_to_length(length):
    """Convert length like '1' to 1000 or '30M' to 30"""

    try:
        if length[-1:] == "M":
            t_length = int(length[:-1])  # Trim off the 'M'
        else:
            t_length = int(float(length) * 1000)  # Convert to meters

        length_str = str(t_length)

    except ValueError:
        length_str = ""

    return length_str