Python Automation

Full-stack Python automation toolkit for file processing, data extraction, PDF manipulation, Excel/workbook automation, web scraping, and system tasks. Use when the user needs to: (1) Process/rename/organize files in bulk, (2) Extract data from PDFs, CSVs, or web pages, (3) Generate or modify Excel reports, (4) Automate repetitive system tasks (cron, file watching), (5) Build quick CLI tools for data processing.

Audits

Pass

Install

openclaw skills install python-automation

Python Automation

Core Libraries Quick Reference

TaskLibraryInstallation
File systempathlib, shutil, osstdlib
CSVcsvstdlib
Excelopenpyxlpip install openpyxl
Excel (old)xlrd / xlwtpip install xlrd xlwt
PDF textPyMuPDF (fitz)pip install PyMuPDF
PDF tablescamelot-py / tabula-pypip install camelot-py
Web scrapingrequests + BeautifulSoup4pip install requests beautifulsoup4
Browser automationplaywright or seleniumpip install playwright
CLIargparse (stdlib) or clickstdlib / pip install click
Rich terminalrichpip install rich
File watchingwatchdogpip install watchdog
Schedulingschedule or cronpip install schedule

Common Patterns

1. Batch File Processing

from pathlib import Path

for f in Path(".").glob("**/*.txt"):
    content = f.read_text()
    # transform content
    f.write_text(content)

2. CSV Read/Write

import csv
with open("input.csv", newline="") as f:
    reader = csv.DictReader(f)
    for row in reader:
        print(row["column_name"])

with open("output.csv", "w", newline="") as f:
    writer = csv.writer(f)
    writer.writerow(["col1", "col2"])
    writer.writerow(["val1", "val2"])

3. Excel Generation

from openpyxl import Workbook
wb = Workbook()
ws = wb.active
ws["A1"] = "Hello"
ws["B1"] = 42
wb.save("output.xlsx")

4. Web Scraping

import requests
from bs4 import BeautifulSoup

resp = requests.get("https://example.com", timeout=10)
soup = BeautifulSoup(resp.text, "html.parser")
for link in soup.select("a[href]"):
    print(link["href"], link.text.strip())

Scripts

See scripts/ for ready-to-use automation scripts:

  • rename_batch.py — Batch rename files with pattern matching
  • csv_to_excel.py — Convert CSV files to Excel workbooks

Reference Files