-
Notifications
You must be signed in to change notification settings - Fork 0
/
7-Presentorabsent.py
61 lines (61 loc) · 2.45 KB
/
7-Presentorabsent.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
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)
extension = ".csv"
file_name = current_date_and_time_string + 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
print("the total number of enteries present in the DataforAttendance file is ",N)
while i<N:
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 >= 2400):
with open(file_name,'r+') as f:
myDatalist = f.readlines()
namelist=[]
for line in myDatalist:
entry=line.split(',')
namelist.append(entry[0])
if column_Name[i] not in myDatalist:
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<2400):
with open(file_name,'r+') as f:
myDatalist = f.readlines()
namelist=[]
for line in myDatalist:
entry=line.split(',')
namelist.append(entry[0])
if column_Name[i] not in myDatalist:
current_date = datetime.date.today()
f.writelines(f'\n{column_Id[i]},{column_Name[i]},{current_date},{"Absent"}')
j=j+2
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]")