• PyByte
  • Posts
  • $100 PDF Merging Program (inside šŸ‘ˆ)

$100 PDF Merging Program (inside šŸ‘ˆ)

and doing the Dall-E 'but more' trend with Python

from PyByte import spotlight_story, deep_dive, byte_break

# Welcome to the PyByte!

šŸ‘‹ Hey everyone! This week’s PyByte may actually save you $$$ šŸ‘€

spotlight_story()

Story time! šŸ‘‡

I occasionally take on projects from businesses who reach out to me to automate their various workflows.

Recently I had a client who reached out because they had a slow, heavily manual process that they thought might be able to automated (spoiler: it was).

Here was their flow:

  1. A folder on their server accumulated invoices for client work in PDF format.

  2. Another folder contained PDF contracts of completed work as the invoiced work finished.

  3. Every day, go through each invoice and find the matching contract, merging all contracts (could be more than one) with that invoice. 🤯

  4. Merge all PDFs into a single document into a new folder.

I hope you’re like me, and are appalled that they were doing this by hand… while simultaneously eager to write a Python script that will turn this from a 2+ hour job to 2 minutes (if you’re really slow).

Now the amazing thing about using Python for this is no matter what format the invoices/contracts are, (Word doc, .txt, .xlsx etc) you can EASILY convert this script to handle those cases thanks to… Python libraries. PyPDF2 is what I used to read PDFs for this project.

Anyway, this client paid $100 for the my time & program, but I wanted to share this script for you for FREE because I found this use-case interesting while very relatable and I so I hope you’ll find a use for it ā¤ļø

deep_dive()

Here’s another money saver… šŸ’°

Downloading YouTube videos using Python!!

That’s right, you don’t need to pay money for a YouTube downloader (although if you want a nice GUI you might) because the library pytube has got you covered.

pytube is a lightweight, Pythonic, dependency-free, library (and command-line utility) for downloading YouTube Videos.

After installing it with:

pip install pytube

You can run the following program to download a video.

from pytube import YouTube

# Replace with the desired video URL
url = 'https://www.youtube.com/watch?v=dQw4w9WgXcQ&ab'

yt = YouTube(url)
video = yt.streams.get_highest_resolution()
video.download()

print(f'Video downloaded successfully: {video.title}')

Here’s how you can use the command-line utility.

Isn’t Python amazing? I am always learning about new things it can do, and I’m so glad I get to share it with you.

byte_break()

I jumped on the Dall-E ā€˜but more’ trend with some funny results. In case you missed it, here’s the post!

One more thing!

Miss Excel is hosting another webinar, this time on Data Cleaning.

You can register here!

Here’s the cool part. If I can get 20 people to sign up for her event, I will host my own webinar on the same thing (but in Python).

If you’re interested in that, let me know with this link:

See you next week šŸ‘‹

Joel