5 Killer Automation Scripts in Python

Ishaan Gupta
CodeX
Published in
2 min readApr 9, 2022

Here are some awesome automation scripts that you can use in your Python projects.

While making projects, we need some ready-made codes that can help us to solve our daily life problems. This article has 5 Automation Scripts for your Python Projects that will solve your problems.

Part 2 of this article — https://medium.com/codex/5-killer-automation-scripts-in-python-part-2-5b5a8995eef8

So bookmark it and let’s get started.

1.) Convert Images to PDF

If you had a lot of images and looking for converting them into a single Pdf then this automation script will be handy for you.

Method 1-

import os
import img2pdf
with open("out.pdf", "wb") as file:
file.write(img2pdf.convert([i for i in os.listdir('Path of image_Directory') if i.endswith(".jpg")]))

Method 2 -

from fpdf import FPDF
Pdf = FPDF()
list_of_images = ["one.jpg", "second.jpg","third.jpg"]for i in list_of_images:
Pdf.add_page()
Pdf.image(i,x,y,w,h)
Pdf.output("out.pdf", "F")

2.) Convert PDF to CSV

Sometimes we need to convert our PDF data into CSV format, So for that kind of work, this Python script will be handy for you.

import tabulafilename = input("Enter File Path: ")df = tabula.read_pdf(filename, encoding='utf-8', spreadsheet=True, pages='1')
df.to_csv('out.csv')

3.) YT Video Downloader

A simple automation script to download Youtube videos. No need of any websites or apps, just use the below code to download any video.

import pytubelink = input('Enter The Youtube Video URL')
dn = pytube.Youtube(link)
dn.streams.first().download()
print('Your Video Has Been Downloaded', link)

4.) InstaDpViewer

This script will download the DP of any Instagram User. It uses module instaloader which takes username as input and downloads the DP as an output.

import instaloaderil = instaloader.Instaloader()
username = input("Enter Insta username ")
il.download_profile(username , profile_pic_only=True)
print("Your DP is Downloaded")

5.) Text to Speech

It uses google Text to Speech API to convert your written Text to AI bot voice.

from pygame import mixer
from gtts import gTTS
def main():
tts = gTTS('Like This Article')
tts.save('output.mp3')
mixer.init()
mixer.music.load('output.mp3')
mixer.music.play()
if __name__ == "__main__":
main()

Final Thoughts

Well, here are some Awesome Automation Python Scripts that can be helpful for you to build your projects. I hope you find this article helpful and have had learn some new things. Share this article with your Pythoneer Friends.

Happy Coding!

--

--

Ishaan Gupta
CodeX
Writer for

Medium Top Writer. CSE Sophomore. Programmer. Developer. Finance Enthusiast.