-
Notifications
You must be signed in to change notification settings - Fork 2
/
mark_attendance.py
33 lines (25 loc) · 1 KB
/
mark_attendance.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
import csv
class Mark_Attendance:
def __init__(self,csv_filename):
self.csv_filename = csv_filename
def write_csv_header(self,id,date,staff_name,time,status):
self.id = id
self.date = date
self.staff_name = staff_name
self.time = time
self.status = status
f = open(self.csv_filename, "w+",newline='')
writer = csv.DictWriter(f, fieldnames=[self.id,self.date,self.staff_name,self.time,self.status])
writer.writeheader()
f.close()
def append_csv_rows(self,records):
self.records = records
with open(self.csv_filename, 'a+',newline='') as f_object:
# Pass this file object to csv.writer()
# and get a writer object
writer_object = csv.writer(f_object)
# Pass the list as an argument into
# the writerow()
writer_object.writerow(self.records)
#Close the file object
f_object.close()