trying to complete a task for my course;
I have two files that I need to read from and compare to get a count. One file contains login information in the format of: username, password
The other file has the tasks in the format of: username, task name, task descrip, date logged, due date, is completed?(Y/N)
I need to read both files and count how many tasks a user in the login information file has in the task file.
This is what I have so far:
user_file = open("user.txt", "r")
user_tasks = open("tasks.txt", "r")
num_users = user_file.readlines()
total_num_users = len(num_users) # This is for a separate part of the task
task_lines = user_tasks.readlines()
my_dict = {}
# TODO use all_file_count for total number of tasks
for user, task in zip(num_users, task_lines):
user = user.strip("\n").split(", ")
task = task.strip("\n").split(", ")
if user[0] == task[0]:
my_dict = dict(zip(user, task))
print(my_dict)
Initially I was just trying to test if I could make it work and display the user and task but I am not sure how to transform it into a count, although I can see that my first hurdle is the above isn't working correctly as I don't have all my users and their tasks that appear in both files.
This is the output:
/Users/Joekelly/PycharmProjects/HyperionDev/venv/bin/python /Users/Joekelly/PycharmProjects/HyperionDev/main.py {'admin': 'admin', 'adm1n': 'Register Users with taskManager.py'}
For reference:
I have attached screenshots of the txt. files enter image description here Please note: This is not real data I am not sharing people's login/passwords :)