These are brand new automation projects for 2023.
Python can be a valuable tool for automating daily tasks, and if you’re currently learning the language, it’s highly recommended that you give it a try.
With the rise of artificial intelligence, machine learning, and robotics, we now have the ability to automate a wide range of tasks, from complex manufacturing processes to simple daily routines. One of the most accessible ways to automate tasks in our daily lives is through programming languages such as Python.
Python is a high-level, general-purpose programming language that is widely used in various fields such as data analysis, web development, and scientific computing. However, Python can also be used to automate mundane and repetitive tasks that we often perform in our daily lives, such as checking emails, downloading files, or even cleaning up our desktops.
The ability to automate such tasks can provide us with more time to focus on more important aspects of our lives, such as spending time with our loved ones, pursuing our hobbies, or simply relaxing. Moreover, automating these tasks can also help us become more productive, organized, and efficient in our daily lives
You’ll find links to the full scripts and tutorials to solve each project.
1. Automated Email Sender (Beginner Friendly)
Python has a built-in library called smtplib
that can be used to send emails automatically. You can create a script that reads the recipient’s email address and the message body from a CSV or Excel file and sends the email using a Gmail or SMTP(Simple Mail Transfer Protocol) server. You can even schedule the script to run at a specific time each day to send daily reports or reminders.
First, you need to set up your Python environment with the required libraries. For this project, you will need the smtplib
and email
libraries. You can install them using the pip command:
Copy code
pip install smtplib
pip install email
- Create a CSV file: You can create a CSV file with the list of recipients and message body. The first column should be the email addresses, and the second column should be the message body.
- Write the script: Here is an example script that reads the CSV file and sends an email to each recipient:
pythonCopy code
import smtplib
import csv
from email.mime.text import MIMEText
from email.mime.multipart import MIMEMultipart
# Sender's email credentials
sender_email = 'your_email@gmail.com'
sender_password = 'your_email_password'
# Read the CSV file
with open('recipients.csv', mode='r') as file:
reader = csv.reader(file)
next(reader) # skip the header row
for row in reader:
recipient_email = row[0]
message = row[1]
# Create the message
msg = MIMEMultipart()
msg['From'] = sender_email
msg['To'] = recipient_email
msg['Subject'] = 'Automatic Email Sender'
msg.attach(MIMEText(message, 'plain'))
# Send the message
with smtplib.SMTP('smtp.gmail.com', 587) as smtp:
smtp.starttls()
smtp.login(sender_email, sender_password)
smtp.send_message(msg)
You can test the script by running it from the command line. Make sure that the CSV file and the script are in the same directory. Also, make sure that you have enabled less secure apps in your Gmail account.
Finally, you can schedule the script to run automatically at a specific time each day using a cron job on a Unix-based system or the Task Scheduler on a Windows system. Alternatively, you can use a cloud-based service such as AWS Lambda or Google Cloud Functions to run the script automatically.
2. Automate Microsoft Word (Beginner Project)
This Python project automates the creation of personalized documents for multiple job candidates. It uses the Pandas library to read a CSV file with fake data for different candidates and iterates through each row to extract the relevant information. The DocxTemplate library is used to generate a document based on a pre-existing template and the extracted data for each candidate. The resulting document includes information about the candidate, such as their name, contact information, and the job position they are applying for, as well as the date of the document generation. Finally, the rendered document is saved with a unique name for each candidate based on their index in the CSV file. This project can save time and increase efficiency for individuals or companies in the hiring process.
Here is the code:
import pandas as pd
from datetime import datetime
from docxtpl import DocxTemplate
doc = DocxTemplate("en-template-manager-info.docx")
my_name = "Frank Andrade"
my_phone = "(123) 456-789"
my_email = "frank@gmail.com"
my_address = "123 Main Street, NY"
today_date = datetime.today().strftime("%d %b, %Y")
my_context = {'my_name': my_name, 'my_phone': my_phone, 'my_email': my_email, 'my_address': my_address,
'today_date': today_date}
df = pd.read_csv('en_fake_data.csv')
for index, row in df.iterrows():
context = {'hiring_manager_name': row['name'],
'address': row['address'],
'phone_number': row['phone_number'],
'email': row['email'],
'job_position': row['job'],
'company_name': row['company']}
context.update(my_context)
doc.render(context)
doc.save(f"generated_doc_{index}.docx")
Note: Ensure that the CSV file is formatted correctly and that the column names match the names used in the script. Also, ensure that the “en-template-manager-info.docx” file is a valid Word document template.
3. Automate Whatsapp messages using pywhatkit
Pywhatkit is a Python library that provides a simple and efficient way to automate sending WhatsApp messages. This can be helpful for individuals who need to send messages to multiple recipients or for businesses that want to automate their customer communication. With Pywhatkit, you can send messages with just a few lines of code, and even schedule messages to be sent at a later time.
However, it is important to use this tool responsibly and with caution. Automated messaging can be seen as spam and can result in your account being blocked or banned. Additionally, the use of automated messaging can have legal implications, depending on the content of the message and the nature of the recipients. It is important to ensure that all messages sent through this tool comply with the relevant laws and regulations.
It is recommended to use Pywhatkit for legitimate and ethical purposes only. When using this tool, make sure to respect people’s privacy, avoid sending unsolicited messages, and only send messages to people who have given you permission to do so. Always use this tool with discretion and care to ensure that it is used in a responsible and ethical manner.
Open your terminal and type pip install pywhatkit
to install the library.
Run Python script:
- Create a new file named
send_message.py
in your preferred text editor or IDE. - Copy and paste the Python code from the previous answer into the
send_message.py
file. - Replace the phone number and message with your own desired recipient phone number and message respectively.
- Modify the
send_time_hour
andsend_time_minute
variables to specify the time you want to send the message. - Save the file.
Run the Python script:
- Open your terminal or command prompt and navigate to the directory where the
send_message.py
file is saved. - Type
python send_message.py
in your terminal or command prompt to run the script. - Pywhatkit will open a new instance of WhatsApp in your default web browser and send the message at the specified time.
Note:
- It’s important to have your computer and phone connected to the internet during the scheduled message sending time for the message to be sent successfully.
import pywhatkit
# Send message to a contact
phone_number = input("Enter phone number: ")
pywhatkit.sendwhatmsg(phone_number, "Test", 7, 21)
pywhatkit.sendwhatmsg(phone_number, "Test", 7, 25, 15, True, 2)
# Send message to a group
group_id = input("Enter group id: ")
pywhatkit.sendwhatmsg_to_group(group_id, "Test Group", 7, 31)
4. Automated File Organizer
This Python script is a useful tool for organizing files by categorizing them based on their extensions. With this script, you can monitor a specific directory and classify any new files that are added to it.
The script allows you to define a dictionary of file categories and their corresponding extensions. For instance, you can have a category for images, with extensions like jpeg, jpg, and png. Similarly, you can define categories for PDFs, datasets, and videos, with their respective extensions.
Once the categories and extensions are defined, the script will create subdirectories for each category in the main directory that you’re monitoring. When a new file is added to the main directory, the script will classify the file based on its extension and move it to the corresponding subdirectory.
It’s important to note that this script should be used with caution, especially when dealing with sensitive or valuable files. Before running the script, it’s recommended to test it with a small number of test files to ensure that it works as intended. Additionally, it’s important to backup your files before running any script that involves moving or modifying them.
This script can be a useful tool for individuals or businesses who want to keep their files organized and easily accessible. With just a few lines of code, you can automate the process of file classification and save time and effort in managing your files.
Code:
import os
import time
# Directory to be monitored
directory = '/path/to/directory'
# Dictionary of file categories and their extensions
categories = {
'Images': ['jpeg', 'jpg', 'png'],
'PDFs': ['pdf'],
'Datasets': ['csv', 'xlsx', 'json'],
'Videos': ['mp4']
}
for category in ['Images', 'PDFs', 'Datasets', 'Videos']:
os.makedirs(os.path.join(directory, category), exist_ok=True)
# Function to classify a file
def classify_file(filename):
# Find the file extension
extension = filename.split('.')[-1]
# Iterate over the categories
for category, extensions in categories.items():
# If the extension matches one of the extensions in the category, move the file
if extension in extensions:
# Construct the file paths
source_path = os.path.join(directory, filename)
dest_path = os.path.join(directory, category, filename)
# Move the file
os.rename(source_path, dest_path)
print(f'Moved {filename} to {category}')
break
# Classify all existing files in the directory
for filename in os.listdir(directory):
classify_file(filename)
# Initial list of files in the directory
initial_files = os.listdir(directory)
while True:
# List of files in the directory after a short sleep
time.sleep(5)
current_files = os.listdir(directory)
# Find the new files
new_files = list(set(current_files) - set(initial_files))
# Classify the new files
for filename in new_files:
classify_file(filename)
# Update the initial list of files
initial_files = current_files
5. Automating Swipe Right on Tinder
This project uses the Python Selenium package to automate the process of swiping right on Tinder profiles and sending a pre-defined opening message. The program uses the Chrome web driver, so the user must provide the path to their local driver executable. The program will launch the Tinder website and automatically start swiping right a specified number of times. If a match is found, the program will send a pre-defined message to the match. If a match is not found, the program will dismiss any pop-up messages that may appear. The user can customize the opening line and the number of swipes to fit their needs.
Here is the code:
from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.chrome.options import Options
import time
# edit pickup line and number of swipes
opening_line = "Hi!"
number_of_swipes = 10
path = # paste your chromedriver path here
service = Service(executable_path=path)
web = 'https://tinder.com/'
options = Options()
options.add_experimental_option("debuggerAddress", "localhost:9222")
driver = webdriver.Chrome(service=service, options=options)
driver.get(web)
time.sleep(3)
for i in range(number_of_swipes):
try:
like_button = driver.find_element(by='xpath', value='//button//span[text()="Like"]')
driver.execute_script("arguments[0].click();", like_button)
time.sleep(2)
its_match_window = driver.find_element(by='xpath', value='//textarea[@placeholder="Say something nice!"]')
its_match_window.send_keys(opening_line)
time.sleep(1)
send_message_button = driver.find_element(by='xpath', value='//button/span[text()="Send"]')
send_message_button.click()
time.sleep(1)
close_its_match_window = driver.find_element(by='xpath', value='//button[@title="Back to Tinder"]')
close_its_match_window.click()
except:
try:
box = driver.find_element(by='xpath', value='//button/span[text()="Maybe Later"] | //button/span[text()="Not interested"] | //button/span[text()="No Thanks"]')
box.click()
except:
pass
The script first imports the necessary modules, including the webdriver
and Options
classes from Selenium, and the time
module. It then sets the opening_line
and number_of_swipes
variables. The user must also specify the path to their Chrome driver executable by editing the path
variable.
The script then creates a Service
object with the specified driver path and sets the web
variable to the Tinder website. It creates an Options
object and adds the debuggerAddress
option to connect to a running Chrome instance for debugging purposes. Finally, it creates a webdriver.Chrome
object with the Service
and Options
objects.
The script opens the Tinder website and waits for 3 seconds to allow the page to load. It then enters a loop that executes the specified number of swipes. In each iteration of the loop, the script attempts to find and click the “Like” button using an XPath expression. If the button is found, it clicks it and waits for 2 seconds.
The script then attempts to find the text box for sending a message to a match using an XPath expression. If the text box is found, it enters the specified opening line and waits for 1 second. It then finds and clicks the “Send” button and waits for 1 second.
The script then finds and clicks the “Back to Tinder” button to close the “It’s a Match!” window. If any exceptions occur during this process, the script attempts to find and click one of the “Maybe Later”, “Not interested”, or “No Thanks” buttons to dismiss any pop-ups that may appear.
Here is the link to the repository containing all these projects, as well as additional ones:
If you’re interested in staying updated on the latest trends and advancements in technology, be sure to follow me on LinkedIn 💼 , Twitter 🐦 and Medium 📝! I share informative articles, insightful posts, and valuable industry insights. Let’s stay connected and continue the conversation on the latest tech advancements and innovative solutions. Don’t forget to give a shout out and say hi! 🤖🚀