Python – Birthday List

March 15, 2024

Birthday List Python Program

Worked on a project for a publication to pull the birthdays of their members quickly.

To help demonstrate what they were working with; they had two Word files containing tables of birthday months, the dates for the month were not in order and not setup the same. Each person who worked on entering the dates did however they wanted.

The first task was to get the information into an organized list. We created an Excel file where the first column was the birthday in 4 digit month year; example birthday of Jan. 7 would be put in as ‘0107’. The next column would be the person’s name as they want it displayed. Next was for the year born, not everybody has this listed, it’s there if they would want to add the calculations in the future.

Now that the data is set they are able to sort it to make sure it’s in date order. Now that it’s organized, in the Excel, we did a sort by the date then by the person’s name. Saved it as a CSV file for the program to read it. The person was ok with running code in VSCode where they can put in the beginning and end dates in the 4 digit code format then get back the names and dates to copy and paste over to their file.

To get a start on the project I used the fake name generator from:

Example of output:
January 31
Dan Carpenter
Peter Parker
Bob Builder
Sandy Sandcastle
Green Forrest

February 1
Peter Pan
Wendy Winds
Leaf Green

For the program:

You can see the code on GitHub, I have commented the code a lot

Quick overview of the code

Importing csv, os

Pointing to the file location and naming that file ‘csvFile’ as a Python variable

User inputs for the start and end dates they need and assigning them to variables.

Then it’s going through the CSV file line by line looking for the start date to show, then when it finds that and each day after it will setup a header by getting the full month spelled out and the day removing any leading zeros. Then display each person that has a birthday that day in a list. Repeating that process for each day till the end date where it will go till it hits a different day then print an end line showing the code is fully done and when the person copies and pastes out they’ll know that everything was copied.

Related Articles

Microsoft Certified: Azure AI Fundamentals

Microsoft Certified: Azure AI Fundamentals

Passed the Microsoft Certified: Azure AI Fundamentals Certification: The graphic was created in Microsoft Image creator with DALL-E where I added the...

read more
AI as your assistant

AI as your assistant

With all the talk of AI will be taking your job and articles like you don’t need to learn coding AI will do it all for you. I’ve been playing around with AI, decided to try to see how much of what AI can be done for me. I use AI generical throughout the post and not...

read more
Website Contact form using AWS

Website Contact form using AWS

For the next iteration of the HTML form was to set it up to send an email to the web owner using AWS. The purpose behind this is, if you have a HTML site and don’t want to purchase a monthly plan or build and maintain server software. Using AWS for this functionality...

read more

Pin It on Pinterest

Share This