Home > Software engineering >  Data redundancy on csv file
Data redundancy on csv file

Time:02-10

Hi Good day everyone I'm sorry I'm new to python programming sorry if I'm asking this even this is basic or not. Someone can help me with this? My problem is I want to write the data that capture's on my open cv Like for example "Name" "Reputation" or something else. And write it to my csv file. It writes But I has a redundancy like per capture it records The same name. I just want one Name that don't redundant Someone can Help me with this Please???

Here's the code to record data to csv:

   def markattend(name,years,pos,tempe):
    with open('attendances.csv','r ') as f:
        datalist = f.readlines()
        nameList = []

        for line in datalist:
            entry = line.split(',')
            nameList.append(entry[0])

        if name and years and pos and tempe not in nameList:
            now = datetime.now()
            dtString = now.strftime('%I:%M:%a:%d:%b:%Y')
            f.writelines(f'\n{name},{years},{pos},{tempe},{dtString}')
        return datalist

And here I call the function and assigning its Data: like "Name" "Position"

if confidence>70:
                cv2.putText(img, datas, (x,y 205), cv2.FONT_HERSHEY_SIMPLEX, 0.8, color, 2, cv2.LINE_AA)
                cv2.putText(img, datas1, (x,y 230), cv2.FONT_HERSHEY_SIMPLEX, 0.8, color, 2, cv2.LINE_AA)
                cv2.putText(img, datas2, (x,y 250), cv2.FONT_HERSHEY_SIMPLEX, 0.8, color, 2, cv2.LINE_AA)
                cv2.putText(img, get_temp(ser), (x,y 280), cv2.FONT_HERSHEY_SIMPLEX, 0.8, color, 2, cv2.LINE_AA)
                markattend(datas,datas1,datas2,get_temp(ser))  <== This temp is from my sensor data

and datas, datas1, datas2 it correspond the "Name" "position" "Student"

Someone can help me plsss

Here's my csv file photo:here's the Image

CodePudding user response:

  •  Tags:  
  • Related