DEV Community

Brad
Brad

Posted on

5 Python Automations Every Small Business Owner Needs Right Now

5 Python Automations Every Small Business Owner Needs Right Now

Running a small business means wearing too many hats. Python automation can give you back hours every week. Here are the 5 scripts that matter most.

1. Automated Invoice Generator

Stop manually creating invoices in Word:

from reportlab.pdfgen import canvas
from reportlab.lib.pagesizes import letter
from datetime import datetime

def generate_invoice(client_name, services, total, invoice_num):
    filename = f"invoice_{invoice_num}.pdf"
    c = canvas.Canvas(filename, pagesize=letter)

    c.setFont("Helvetica-Bold", 24)
    c.drawString(50, 750, "INVOICE")
    c.setFont("Helvetica", 12)
    c.drawString(50, 720, f"Invoice #: {invoice_num}")
    c.drawString(50, 700, f"Date: {datetime.now().strftime('%B %d, %Y')}")
    c.drawString(50, 680, f"Client: {client_name}")

    y = 620
    for service, amount in services:
        c.drawString(50, y, service)
        c.drawString(400, y, f"${amount:.2f}")
        y -= 25

    c.setFont("Helvetica-Bold", 14)
    c.drawString(350, y - 20, f"TOTAL: ${total:.2f}")
    c.save()
    return filename

invoice = generate_invoice(
    client_name="Acme Corp",
    services=[("Web Development - 10 hrs", 750), ("SEO Consultation", 200)],
    total=950,
    invoice_num="2024-001"
)
print(f"Invoice created: {invoice}")
Enter fullscreen mode Exit fullscreen mode

Time saved: 20 min/invoice x 10/month = 3.3 hours/month

2. Email Follow-Up Automation

Never let a lead go cold:

import smtplib
import json
from email.mime.text import MIMEText
from datetime import datetime

def send_followup(lead_email, lead_name, days_since_contact):
    templates = {
        3: f"Hi {lead_name}, checking in about your project...",
        7: f"Hi {lead_name}, wanted to share some ideas...",
        14: f"Hi {lead_name}, last follow-up - let me know if timing changes."
    }

    message = templates.get(days_since_contact)
    if not message:
        return False

    msg = MIMEText(message)
    msg['Subject'] = f"Following up, {lead_name}"
    msg['From'] = 'you@yourbusiness.com'
    msg['To'] = lead_email

    with smtplib.SMTP_SSL('smtp.gmail.com', 465) as server:
        server.login('you@yourbusiness.com', 'your_app_password')
        server.send_message(msg)
    return True

# Load leads and send appropriate follow-ups
with open('leads.json') as f:
    leads = json.load(f)

today = datetime.now()
for lead in leads:
    last = datetime.strptime(lead['last_contact'], '%Y-%m-%d')
    days = (today - last).days
    if days in [3, 7, 14]:
        send_followup(lead['email'], lead['name'], days)
        print(f"Sent {days}-day follow-up to {lead['name']}")
Enter fullscreen mode Exit fullscreen mode

Time saved: 30 min/day x 22 days = 11 hours/month

3. Expense Tracker

Know where your money goes automatically:

import csv
from collections import defaultdict
import matplotlib.pyplot as plt
from datetime import datetime

def analyze_expenses(csv_file):
    expenses = defaultdict(float)

    with open(csv_file) as f:
        for row in csv.DictReader(f):
            category = row.get('Category', 'Other')
            expenses[category] += float(row.get('Amount', 0))

    print("=== EXPENSE BREAKDOWN ===")
    for cat, total in sorted(expenses.items(), key=lambda x: -x[1]):
        print(f"  {cat}: ${total:.2f}")

    plt.pie(expenses.values(), labels=expenses.keys(), autopct='%1.1f%%')
    plt.title('Monthly Expenses')
    plt.savefig('expense_chart.png', dpi=150, bbox_inches='tight')
    print("Chart saved!")

analyze_expenses('bank_export.csv')
Enter fullscreen mode Exit fullscreen mode

Time saved: 2 hours/month on bookkeeping prep

4. Social Media Scheduler

Post consistently without spending your day on it:

import tweepy, json, time
from datetime import datetime

def schedule_posts(posts_file, client):
    with open(posts_file) as f:
        posts = json.load(f)

    for post in posts:
        scheduled = datetime.strptime(post['time'], '%Y-%m-%d %H:%M')
        now = datetime.now()

        if scheduled > now:
            wait = (scheduled - now).total_seconds()
            print(f"Waiting {wait:.0f}s to post...")
            time.sleep(wait)

        client.create_tweet(text=post['text'])
        print(f"Posted: {post['text'][:50]}")

# posts.json: [{"time": "2024-01-15 09:00", "text": "Your post #business"}]
Enter fullscreen mode Exit fullscreen mode

Time saved: 1 hour/week = 4 hours/month

5. Competitor Price Monitor

Know the moment competitors change prices:

import requests
from bs4 import BeautifulSoup
import time

def monitor_prices(products, check_interval=3600):
    baselines = {p['name']: p['baseline_price'] for p in products}

    while True:
        for product in products:
            try:
                resp = requests.get(product['url'], headers={
                    'User-Agent': 'Mozilla/5.0'
                }, timeout=10)
                soup = BeautifulSoup(resp.text, 'html.parser')
                price_el = soup.select_one(product['selector'])

                if price_el:
                    price = float(price_el.get_text().strip().replace('$', '').replace(',', ''))
                    baseline = baselines[product['name']]
                    change_pct = ((price - baseline) / baseline) * 100

                    if abs(change_pct) > 5:
                        print(f"ALERT: {product['name']} changed {change_pct:+.1f}% to ${price}")

            except Exception as e:
                print(f"Error: {e}")

        time.sleep(check_interval)
Enter fullscreen mode Exit fullscreen mode

The ROI Math

  • Invoice automation: 3.3 hrs/month
  • Email follow-ups: 11 hrs/month
  • Expense reporting: 2 hrs/month
  • Social scheduling: 4 hrs/month

Total: 20+ hours/month saved at $50/hr = $1,000/month in freed time


Want all 5 of these scripts plus 7 more in one ready-to-run package? Email automation, database backup, API monitoring, and more.

Python Business Automation Toolkit → $9 one-time

12 production-ready scripts, tested and documented.

Top comments (0)