Skip to content

This is a repo for a 1 up workshop to describe how to solve real life problems using python, and how to think through the steps of the problem.

Notifications You must be signed in to change notification settings

CodingTemple/1up---Automated-Weather-Based-Email

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Automated Weather-Based Email Workshop

Overview

This workshop covers the development of a Python application that reads client data from a CSV file, checks the current weather for each client's city using an API, and sends out promotional emails based on the weather condition (rain).

Objectives

  • Understand how to read data from CSV files in Python.
  • Learn how to make API requests to gather weather data.
  • Automate sending emails based on data-driven conditions.

Key Python Packages

csv

  • Purpose: To read from and write to CSV files in Python.
  • Usage in Project: We use csv.DictReader to read client data from a CSV file and process it as a list of dictionaries.

requests

  • Purpose: To send HTTP requests in Python, essential for API interactions.
  • Usage in Project: Used to make GET requests to the OpenWeatherMap API to fetch current weather data for each client's city.

sendgrid

  • Purpose: SendGrid's Python library, used for sending emails through the SendGrid platform.
  • Usage in Project: Utilized to programmatically send emails to clients. This includes composing the email and handling the sending process.

os

  • Purpose: Provides a way of using operating system dependent functionality like reading or writing to the environment variables.
  • Usage in Project: Used to access API keys stored in environment variables for security purposes.

dotenv

  • Purpose: To load environment variables from a .env file into the script, which is crucial for not hardcoding sensitive data like API keys.
  • Usage in Project: Implemented at the start of the script to load the OpenWeatherMap and SendGrid API keys.

Workshop Flow

  1. Introduction to the Project: Understanding the goal and the steps involved.
  2. Setting Up the Environment: Installing necessary packages and setting up API keys.
  3. Reading and Understanding CSV Data: Using the csv package to read client data.
  4. API Interaction for Weather Data: Making GET requests to OpenWeatherMap API using the requests package.
  5. Automating Email Dispatch: Composing and sending emails through SendGrid using the sendgrid package.
  6. Bringing It All Together: Writing the main script to automate the entire process.
  7. Testing and Troubleshooting: Running the script and analyzing the results.

Additional Resources

Conclusion

This workshop provides a hands-on experience in automating a practical task using Python. It combines data handling, API interaction, and email automation, offering a glimpse into the power of Python for real-world applications.

About

This is a repo for a 1 up workshop to describe how to solve real life problems using python, and how to think through the steps of the problem.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •  

Languages