def file_split_user(filename, file_direct, file_users):
    """ Function to split large raw trip data sets based on userIDs

    :param filename - file location for input data
    :param file_direct - main directory for all files to be saved to
    :param file_users - number of users to have trips in each file

    file_split_user(str, str, int) -> None
    """
    count = 1
    user_id = {}
    fhand_in = open(filename, 'r')
    fhand_out = open(file_direct + str(count) + '.txt', 'w')
    for line in fhand_in:
        a = line.split(',')
        if a[3] not in user_id:
            user_id[a[3]] = 0
        if len(user_id) <= file_users:
            fhand_out.write(line)
        elif len(user_id) > file_users:
            fhand_out.close()
            user_id = {}
            count += 1
            fhand_out = open(file_direct + str(count) + '.txt', 'w')
            user_id[a[3]] = 0
            fhand_out.write(line)
    fhand_out.close()
    fhand_in.close()
