I have a task where I have to create a summary of each users tasks which are listed in a txt file. For example the summary must include how many tasks are assigned to each user, how many have been completed, how many are overdue etc. I figured out a very simplistic system where I create a list for each user, however this is not modular at all, because if a new user is created it will completely overlook them. I am really struggling to come up with some modular logic, so any help will be greatly appreciated.
The text file is structured as follows: user name, task title, task description, due date, issued date, completed (Yes/No) e.g.:
james, hello, hello world, 30/Jun/2022, 26 May 2022, Yes
I don't have a lot of code for this, as I am not sure where to begin but this is what I have so far:
# For user overview:
# Creating new txt.file for summary to be output in
user_ov = open('user_overview.txt','w+')
# Opening and reading task text file
task_file = open('tasks.txt','r+')
task_content = task_file.readlines()
# Isolating specific users tasks by name
for line in task_content:
split_task = line.split(", ")
user_name = split_task_cont[0]
for user_name in task_content:
user_name = []
# Calculating the length of all the created lists
num_users = len(file_content)
# Writing the values into the txt file
user_ov.write(f"The total number of users is {length_user}\n")
user_ov.write(f"The total number of tasks is {length_task}\n")