-
Notifications
You must be signed in to change notification settings - Fork 0
/
8-PresentorAbsentformultiple.py
96 lines (95 loc) · 4.1 KB
/
8-PresentorAbsentformultiple.py
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
import pandas as pd
import datetime
import csv
current_date_and_time = datetime.date.today()
current_date_and_time_string = str(current_date_and_time)
subject=input("enter the subject or subject code- for this class")
extension = ".csv"
file_name = current_date_and_time_string+"_"+subject+ extension
df = pd.read_csv('FinalAttendance_syntax.csv')
df.drop(df.index[0:], inplace = True)
df.to_csv(file_name, index = False)
my_csv = pd.read_csv("Dataforattendance.csv")
column_Name = my_csv.Name
column_Time= my_csv.timeinseconds
column_Id=my_csv.Id
N=len(column_Name)
i=0
if((N/2)%2==0):
while i<N-((N/2)):
j=1
while j<N:
if(column_Name[i]==column_Name[j])and(column_Id[i]==column_Id[j]):
if(column_Time[i]<column_Time[j]):
entry_time=(column_Time[i])
exit_time=(column_Time[j])
else:
entry_time=(column_Time[i])
exit_time=(column_Time[j])
total_time=exit_time - entry_time
if(total_time >= 6):
with open(file_name,'r+') as f:
myDatalist = f.readlines()
namelist=[]
for line in myDatalist:
entry=line.split(',')
namelist.append(entry[0])
current_date = datetime.date.today()
f.writelines(f'\n{column_Id[i]},{column_Name[i]},{current_date},{"Present"}')
elif(total_time==0):
j=j+1
continue
elif(total_time<6):
with open(file_name,'r+') as f:
myDatalist = f.readlines()
namelist=[]
for line in myDatalist:
entry=line.split(',')
namelist.append(entry[0])
current_date = datetime.date.today()
f.writelines(f'\n{column_Id[i]},{column_Name[i]},{current_date},{"Absent"}')
j=j+1
i=i+1
elif((N/2)%2==1):
while i<N-((N/2)):
j=1
while j<N:
if(column_Name[i]==column_Name[j])and(column_Id[i]==column_Id[j]):
if(column_Time[i]<column_Time[j]):
entry_time=(column_Time[i])
exit_time=(column_Time[j])
else:
entry_time=(column_Time[i])
exit_time=(column_Time[j])
total_time=exit_time - entry_time
if(total_time >= 600):
with open(file_name,'r+') as f:
myDatalist = f.readlines()
namelist=[]
for line in myDatalist:
entry=line.split(',')
namelist.append(entry[0])
current_date = datetime.date.today()
f.writelines(f'\n{column_Id[i]},{column_Name[i]},{current_date},{"Present"}')
elif(total_time==0):
j=j+1
continue
elif(total_time<600):
with open(file_name,'r+') as f:
myDatalist = f.readlines()
namelist=[]
for line in myDatalist:
entry=line.split(',')
namelist.append(entry[0])
current_date = datetime.date.today()
f.writelines(f'\n{column_Id[i]},{column_Name[i]},{current_date},{"Absent"}')
j=j+1
i=i+1
print("[INFO:THE ATTENDANCE FILE HAS BEEN UPDATED FOR TODAY]")
print("[Erasing the Datforattendance file")
print(".....")
print(".....")
df = pd.read_csv('Dataforattendance.csv')
df.drop(df.index[0:], inplace = True)
df.to_csv('Dataforattendance.csv', index = False)
print("[Erased the data]")