i have field (name, time, date ,latest time) if name not in name list i just write name,time and date but if name was into namelist i want to update and add latest time into that row file Csv Example
if choice == 'LOGIN':
st.markdown("<h2 style='text-align: center; color: black;'>ATTEDANCE</h2>", unsafe_allow_html=True) #title
with col1: #column 1
st.subheader("LOGIN")
run = st.checkbox("Run camera") #checkbox
run2 = st.checkbox("Run camera2") #checkbox
if run == True:
for cl in myList: #loop
curlImg = cv2.imread(f'{path}/{cl}') #read image
images.append(curlImg)
classNames.append(os.path.splitext(cl)[0]) #split image name
print(classNames)
def findEncodings(images): #find encoding
encodeList = []
for img in images:
img = cv2.cvtColor(img,cv2.COLOR_BGR2RGB)
encode = face_recognition.face_encodings(img)[0]
encodeList.append(encode)
return encodeList
def faceList(name):
with open('absensi.csv', 'r+') as f:
myDataList = f.readlines()
nameList = []
for line in myDataList:
entry = line.split(',')
nameList.append(entry[0])
if name not in nameList:
now = datetime.now()
dtString = now.strftime('%H:%M:%S')
today = date.today()
dtString2 = now.strftime('%d/%m/%Y')
print("Today's date:", today)
f.writelines(f'\n{name},{dtString},{dtString2}')
encodeListUnkown = findEncodings(images)
print('encoding complate!')