-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinfo.py
More file actions
76 lines (58 loc) · 2.46 KB
/
Copy pathinfo.py
File metadata and controls
76 lines (58 loc) · 2.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
import csv
import random
from datetime import datetime
import json
input_csv_path = 'history/Schedule.csv'
with open('conf/projects.json', 'r', encoding='utf-8') as f:
projects = json.load(f)
# Initialize completed_tasks dictionary
completed_tasks = {}
# Read completed tasks from the uploaded_work_schedule.csv file
def read_completed_tasks_from_csv():
with open(input_csv_path, mode='r', newline='', encoding='utf-8') as f:
reader = csv.reader(f)
next(reader) # Skip header row
for row in reader:
if len(row) == 0: # Skip empty rows
continue
date, projectname, project_id, task_name, work_hours = row
if project_id not in completed_tasks:
completed_tasks[project_id] = []
completed_tasks[project_id].append({'task': task_name, 'hours': float(work_hours)})
# Read completed tasks from the uploaded CSV file
read_completed_tasks_from_csv()
# print(completed_tasks)
# Display the updated projects for verification
# print(updated_projects)
# Your function to print remaining work hours
def print_remaining_hours():
for project_details in projects:
project_id = project_details['id']
remaining_hours = project_details['total_hours']
for task in completed_tasks.get(project_id, []):
remaining_hours -= task['hours']
print(f"{project_id} ({project_details['name']}: {project_details['total_hours']} H) - remaining hours:{remaining_hours} H")
def total_remaining_hours():
total_hours = 0.0
for project_details in projects:
project_id = project_details['id']
remaining_hours = project_details['total_hours']
for task in completed_tasks.get(project_id, []):
remaining_hours -= task['hours']
total_hours += remaining_hours
return total_hours
def total_projects_hours():
total_hours = 0.0
for project_details in projects:
project_id = project_details['id']
project_hours = project_details['total_hours']
total_hours += project_hours
return total_hours
# Print remaining work hours for each project
print_remaining_hours()
tph = total_projects_hours()
trh = total_remaining_hours()
tuh = tph - trh
print(f"**Total project hours: {tph} H, Total remaining project hours: {trh} H, Total used hours: {tuh} H**")
# Here follows the rest of your code
# ... (your projects, project_tasks, initialize_csv, and generate_priority_work_schedule functions)