DEV Community

vesper_finch
vesper_finch

Posted on

5 Python Scripts That Save Me Hours Every Week (All Open Source)

Here are 5 Python scripts I use regularly that have genuinely saved me time. All open source, all zero or minimal dependencies.

1. CSV Cleaner — Fix Messy Data Files

Every CSV from a client or API export is a disaster. Different date formats, null values written 10 different ways, duplicate rows, whitespace everywhere.

python csv_cleaner.py messy_export.csv -o clean.csv
Enter fullscreen mode Exit fullscreen mode

It auto-detects encoding, normalizes nulls, standardizes column names to snake_case, removes duplicates, and normalizes dates. Zero dependencies.

Get it: github.com/vesper-astrena/csv-cleaner

2. PromptLab — Test LLM Prompts Before Shipping

If you are integrating LLMs into your app, you need to test prompt variations systematically. PromptLab lets you define templates with variables and compare them side-by-side.

python promptlab.py templates/summarization.yaml --var input="Your text here"
Enter fullscreen mode Exit fullscreen mode

Measures response time, token count, and estimated cost per call. Includes 15 ready-to-use prompt templates.

Get it: github.com/vesper-astrena/promptlab

3. Polymarket Scanner — Find Prediction Market Mispricings

Scans 10,000+ prediction markets for logical inconsistencies and mispricings. No API key needed.

python polymarket_scanner.py
Enter fullscreen mode Exit fullscreen mode

Detects exclusive outcome deviations, ladder contradictions, and more.

Get it: github.com/vesper-astrena/polymarket-scanner

4. Quick File Renamer

A 30-line script I keep around for batch-renaming files with regex:

import os, re, sys

pattern = sys.argv[1]  # regex pattern
replacement = sys.argv[2]  # replacement string
directory = sys.argv[3] if len(sys.argv) > 3 else "."

for filename in os.listdir(directory):
    new_name = re.sub(pattern, replacement, filename)
    if new_name != filename:
        os.rename(
            os.path.join(directory, filename),
            os.path.join(directory, new_name)
        )
        print(f"{filename} -> {new_name}")
Enter fullscreen mode Exit fullscreen mode

Usage: python rename.py "IMG_(\d+)" "photo_" ./photos/

5. JSON Flattener

Nested JSON from APIs is painful to work with. This flattens it:

def flatten(obj, prefix=""):
    items = {}
    if isinstance(obj, dict):
        for k, v in obj.items():
            items.update(flatten(v, f"{prefix}{k}."))
    elif isinstance(obj, list):
        for i, v in enumerate(obj):
            items.update(flatten(v, f"{prefix}{i}."))
    else:
        items[prefix.rstrip(".")] = obj
    return items

# {"user": {"name": "John", "address": {"city": "NYC"}}}
# -> {"user.name": "John", "user.address.city": "NYC"}
Enter fullscreen mode Exit fullscreen mode

What Python scripts save you the most time? Drop them in the comments.

Top comments (0)