import ipaddress


def generate_list_from_file(data_file):
    """
    Generate a list from a given file containing a single line of desired data, intended for IPv4 and passwords.

    Args:
        data_file: A file containing a single password or IPv4 address per line

    Returns:
        A list of passwords, IPv4
    """
    print("Generating data list from: {}".format(data_file))
    data_list = []
    with open(data_file, 'r') as my_file:
        for line in my_file:
            try:
                ip = line.strip('\n').strip(' ')
                ipaddress.ip_address(ip)
                data_list.append(ip)
            except:
                print("{} is not an IPv4 address".format(line))
                pass
    return data_list