DEV Community

Cover image for 🐍 Part 2: 5 More Python Scripts That Will Save You Hours Every Week!!
Nishkarsh Pandey
Nishkarsh Pandey

Posted on

🐍 Part 2: 5 More Python Scripts That Will Save You Hours Every Week!!

Back with 5 more small-but-mighty Python scripts to automate your everyday tasks and boost your productivity!!

πŸ“§ 1. Email Yourself a Daily Journal Entry
Save thoughts, goals, or reflections β€” delivered straight to your inbox.

import smtplib
from email.mime.text import MIMEText

body = input("What's on your mind today?\n")
msg = MIMEText(body)
msg['Subject'] = 'πŸ“ Daily Journal'
msg['From'] = 'you@example.com'
msg['To'] = 'you@example.com'

server = smtplib.SMTP('smtp.gmail.com', 587)
server.starttls()
server.login('you@example.com', 'your_app_password')
server.send_message(msg)
server.quit()

Enter fullscreen mode Exit fullscreen mode

βœ”οΈ Use an App Password if using Gmail.

πŸ—‚οΈ 2. Convert CSV to JSON in Seconds.
Perfect for web devs, APIs, or when switching formats.

import csv
import json

with open('data.csv', 'r') as f:
    reader = csv.DictReader(f)
    rows = list(reader)

with open('data.json', 'w') as f:
    json.dump(rows, f, indent=4)

Enter fullscreen mode Exit fullscreen mode

βœ”οΈ Swap CSV β†’ JSON or vice versa with a quick tweak.

πŸ” 3. Find and Replace Text in Multiple Files
Update project files, configs, or logs in bulk.

import os

folder = 'my_project'
for file in os.listdir(folder):
    if file.endswith('.txt'):
        path = os.path.join(folder, file)
        with open(path, 'r+') as f:
            content = f.read().replace("OLD_TEXT", "NEW_TEXT")
            f.seek(0)
            f.write(content)
            f.truncate()

Enter fullscreen mode Exit fullscreen mode

βœ”οΈ Automate tedious refactoring or content cleanup.

🎡 4. Download YouTube Videos as MP3 (Audio Only).
Use this responsibly and for personal content.

from pytube import YouTube

url = input("YouTube URL: ")
yt = YouTube(url)
stream = yt.streams.filter(only_audio=True).first()
stream.download(filename="audio.mp3")

Enter fullscreen mode Exit fullscreen mode

βœ”οΈ Turn lectures, podcasts, or tutorials into offline audio.

🌐 5. Check If Your Internet Is Working (and Speed)

import speedtest

st = speedtest.Speedtest()
print(f"Download: {st.download() / 1_000_000:.2f} Mbps")
print(f"Upload: {st.upload() / 1_000_000:.2f} Mbps")

Enter fullscreen mode Exit fullscreen mode

βœ”οΈ Use in automation or when debugging slow web apps.

πŸͺ§ Like These? Here's What You Can Do:
βœ… Bookmark this post
πŸ’¬ Comment your favorite one
πŸ”” Follow me β€” because Part 3 might be next πŸ‘€

Top comments (1)

Collapse
 
avanichols_dev profile image
Ava Nichols

I always thought Python was mostly for big projects, but seeing these quick scripts really made me realize how much it can help with everyday tasks. The CSV to JSON and internet speed tester were especially eye-opening for me!