Skip to content
  • About
  • 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
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

    [professional_resume]

    Read More Continue

  • Latest

    Explore Generative AI with the Gemini API in Vertex AI

    Read More Explore Generative AI with the Gemini API in Vertex AIContinue

  • Latest

    Inspect Rich Documents with Gemini Multimodality and Multimodal RAG

    Read More Inspect Rich Documents with Gemini Multimodality and Multimodal RAGContinue

  • Latest

    🎓 Why Original Work Matters in Your Final Year Project (And How It Can Shape Your Career)

    In engineering colleges across the country, final year projects are often treated as just another academic task. But what many students fail to realize is…

    Read More 🎓 Why Original Work Matters in Your Final Year Project (And How It Can Shape Your Career)Continue

  • Latest

    🎓 How to Choose Your Final Year Project: A Practical Guide for BTech Students

    Choosing the right final year project is one of the most important decisions of your engineering journey. It’s more than just a submission — it’s…

    Read More 🎓 How to Choose Your Final Year Project: A Practical Guide for BTech StudentsContinue

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

© 2025 - All Rights Reserved

  • About
  • 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.