Am not able to get the senders count who are >= 5

import re, csv
import pandas as pd

class OTPAnalysis:
def init(self) → None:
self.total_otp =
self.count = 0
self.df = None
self.sender_count = {}
self.senders_above_5 = set()

def read_excel_file(self):
    try:
        self.df = pd.read_excel("100-contacts.xlsx")            
        self.otp_filtration(self.df)
    except pd.errors.ParserError as e:
        print(f"Error parsing CSV file: {e}")
        exit(1)

def otp_filtration(self, data):
    for index, row in data.iterrows():
        send = str(row["sender"])
        preview = str(row["Content"])
        try:
            pattern = (r"\b\d{4,8}\b")
            pattern_match = re.search(pattern, preview)
            if pattern_match:
                otp_found_value = pattern_match.group()
                if otp_found_value:
                    get_content = re.findall(r"[A-Za-z]", preview)
                    if get_content:
                        unique_count_sender = self.unique_sender_count(row)                            
                        self.total_otp.append(preview)
                        print(f"Code : {otp_found_value} and preview : {preview} and sender : {send}")
                            
        except Exception as e:
            print(f"Error processing row: {e}")

def unique_sender_count(self, row_sender):
    sender = row_sender["sender"]
    if sender not in self.sender_count:
        self.sender_count[sender] = 1
    else:
        self.sender_count[sender] += 1

    if self.sender_count[sender] >= 5:
        self.senders_above_5.add(sender)
    else:
        pass 

if name == “main”:
otp_filter = OTPAnalysis()
otp_filter.read_excel_file()
print(f"Total number of OTP : {len(otp_filter.total_otp)}")

Please Tell us what’s happening in your own words.

Learning to describe problems is hard, but it is an important part of learning how to code.

Also, the more you say, the more we can help!

I am trying to get the unique senders those who send the messages greater than or equal to 5.

I am reading the excel file and the parsing those data in the otp_filtration function and then am getting the Content column data which contains OTP using the regex pattern and then again am using the condition that the OTP should be with any of the text (example: your opt is 1234) there after am calling the function unique_sender_count to know the senders who has sent more than or equal to 5 and once it hits the condition then am adding it into a senders_above_5 set. And then based on these if the sender sends more than or equal to 5 then i should store all the messages that the sender has sent.
Ex: Sender A → sent 6 OTP messages with content. then I should store all the 6 OTP messages with content. and
Sender B → sent 4 OPT messages then my code should ignore these Sender B.

But here my condition is not working properly and am not sure where am lacking.

So, here i couldn’t able to get the >=5 senders and am getting all the otp’s which has content.