Skip to content
Nishant Munjal
  • About
  • NMRIL Labs
  • Courses
  • ResearchExpand
    • Research Publications
    • Books
    • Patents
    • Ph.D. Supervised
  • Workshop/Conferences
  • ToolsExpand
    • Creative Image Converter
    • Creative QRCode Generator
    • Creative QR Code Generator Tool
    • EMI Calculator
    • SIP Calculator
  • Blog
  • Resume
One Page CV
Nishant Munjal
Python

Churn Email: Day of the Week

Python Project – Churn Emails – Find Which Day of the Week the Email was sent

Write a function find_email_sent_days which reads the file /datasets/project/mbox-short.txt and categorizes each mail message by which day of the week the email was sent.

To do this do the following:

  • Open the file and read it line by line
  • Look for lines that start with “From“
  • For those lines which start from “From“, then look for the third word and keep a running count of each of the days of the week. How do you find the day of the week, is an exercise for you.

Note: You have to store the results in a dictionary. Only store those day of the week that exists. For Example, if there is no line for Mon then it should not be in the dictionary elements.

  • At the end of the program return the contents of your dictionary (order does not matter)

Sample Lines from the file:

From stephen.marquard@uct.ac.za Sat Jan  5 10:14:16 2008
From stephen.marquard@uct.ac.za Sat Jan  5 15:14:16 2008
From stephen.marquard@uct.ac.za Sun Jan  6 09:14:16 2008

Output:

{'Sat': 2, 'Sun': 1}

PS – If your logic is correct then your function should return this dictionary {'Sat': 1, 'Fri': 20, 'Thu': 6}.

Code:

def find_email_sent_days():
    with open("/cxldata/datasets/project/mbox-short.txt") as f:
        days = [i.split(' ')[2] for i in f if i.startswith('From ')]
        print (days)
        dic = {}
        for day in days:
            dic[day] = days.count(day)        
        return dic

Post navigation

Previous Previous
Compute the Compound Interest.py
NextContinue
Churn Emails – Count Number of Messages
  • Latest

    What is CSP Bypass?

    What is CSP Bypass? CSP (Content Security Policy) is a browser security feature that tries to stop attacks like XSS (Cross-Site Scripting) by controlling what…

    Read More What is CSP Bypass?Continue

  • Cybersecurity

    Cybersecurity Tools

    Cybersecurity Tools 1️⃣ Digital Forensics Tools Tool Name Type Used For Who Uses Autopsy Computer forensics Analyze hard disk, recover deleted files Investigators FTK Imager…

    Read More Cybersecurity ToolsContinue

  • Cybersecurity

    Command Injection Attack

    Command Injection Attack A Command Injection attack happens when a web application takes user input and passes it to the system shell (Linux/Windows command line)…

    Read More Command Injection AttackContinue

  • Cybersecurity

    CSRF in DVWA (for learning/demo)

    CSRF in DVWA (for learning/demo) CSRF: An attack where a logged-in user is tricked into sending unwanted requests to a web application, causing actions to…

    Read More CSRF in DVWA (for learning/demo)Continue

  • Cybersecurity

    XSS = Cross-Site Scripting using DVWA

    XSS = Cross-Site Scripting using DVWA It allows an attacker to inject JavaScript into a web page so that it runs in another user’s browser….

    Read More XSS = Cross-Site Scripting using DVWAContinue

Nishant Munjal

Coding Humanity’s Future </>


Facebook Twitter Linkedin YouTube Github Email

Tools

  • SIP Calculator
  • EMI Calculator
  • Creative QR Code
  • Image Converter

Resources

  • Blog
  • Contact
  • Refund and Returns

Legal

  • Disclaimer
  • Privacy Policy
  • Terms and Conditions

© 2026 Nishant Munjal - All Rights Reserved

  • About
  • NMRIL Labs
  • Courses
  • Research
    • Research Publications
    • Books
    • Patents
    • Ph.D. Supervised
  • Workshop/Conferences
  • Tools
    • Creative Image Converter
    • Creative QRCode Generator
    • Creative QR Code Generator Tool
    • EMI Calculator
    • SIP Calculator
  • Blog
  • Resume
Download CV
We use cookies to ensure that we give you the best experience on our website. If you continue to use this site we will assume that you are happy with it.