Unsung Heroes: Top 25 Lesser-Known Python Libraries to Simplify Your Daily Workflow.

I am Developer, Artist and trying my luck on blogging as well. Well I am Ambitious, Passionate towards Learning, The Night Owl, And I Like challenges...
Search for a command to run...

I am Developer, Artist and trying my luck on blogging as well. Well I am Ambitious, Passionate towards Learning, The Night Owl, And I Like challenges...
No comments yet. Be the first to comment.
In this series you will get the fundamentals of python programming, and it will help you write a clean and effective scripts in future.
Introduction: JSON (JavaScript Object Notation) is a widely used data interchange format, especially in web development and configuration management. When dealing with JSON data, it's common to encounter scenarios where you need to compare two JSON o...
Post #2 in the Complete Prompt Engineering Series Welcome back! In What is Prompt Engineering? A Complete Introduction, you learned what prompt engineering is and why it matters. Now we're going deeper: understanding the engine under the hood. You do...

Welcome to the future of human-AI collaboration. If you're reading this in 2024-2025, you're witnessing a fundamental shift in how humans interact with machines—and prompt engineering is your passport to this new world. The Definition: What Exactly I...
In this post, we’ll walk through the anatomy of a great prompt, illustrate every step with vivid examples, and even peek under the hood to see what happens technically when you hit “send.” By the end, you’ll be able to craft prompts that unlock the f...

What is GenAI and Why Does Prompting Matter? If you’ve ever wondered how people interact with AI tools, or why some folks seem to get exactly what they want from tools like ChatGPT while others receive confusing or generic responses, this article is ...

Let’s be honest—being a developer isn’t just about writing code. It’s about solving problems, dealing with burnout, handling meetings, chasing deadlines, and finding time to learn, debug, and ship. But in the middle of this chaos, one simple habit ca...

Python's extensive library ecosystem is a goldmine of tools that can turbocharge your daily coding tasks. While libraries like NumPy, Pandas, and Matplotlib are celebrated, a host of lesser-known Python libraries can revolutionize your daily work. In this article, we'll delve into the top 25 hidden gems that may have slipped under your radar but hold immense potential to enhance your productivity. Each library will be accompanied by practical examples to illustrate its utility.
Dealing with dates and times can be a source of frustration, but Arrow simplifies the process with its user-friendly API. Say goodbye to obscure datetime formats and cumbersome calculations.
Example:
import arrow
now = arrow.now()
tomorrow = now.shift(days=1)
print(tomorrow.format('YYYY-MM-DD'))
Fuzzywuzzy is your secret weapon for approximate string matching. It calculates similarity scores between strings, making it perfect for tasks like deduplication or record linkage.
Example:
from fuzzywuzzy import fuzz
similarity = fuzz.ratio("apple", "apples")
print(similarity) # Output: 91
Pyquery simplifies web scraping with its intuitive jQuery-like syntax. No more wrestling with complex selectors; Pyquery makes extracting data from HTML or XML documents a breeze.
Example:
from pyquery import PyQuery as pq
html = "<div><p>Hello, World!</p></div>"
doc = pq(html)
text = doc('p').text()
print(text) # Output: Hello, World!
Displaying data in tabular form is made elegant with PrettyTable. It allows you to generate attractive ASCII tables from your data, making your reports and presentations shine.
Example:
from prettytable import PrettyTable
table = PrettyTable()
table.field_names = ["Name", "Age"]
table.add_row(["Alice", 28])
table.add_row(["Bob", 35])
print(table)
Rich enhances terminal-based applications, enabling you to create colourful text-based user interfaces for command-line applications. Impress your users with visually appealing outputs.
Example:
from rich import print
print("[bold green]Hello, World![/bold green]")
Typer is your go-to library for rapidly developing command-line interfaces (CLIs). It simplifies argument parsing and helps text generation, reducing the hassle of CLI development.
Example:
import typer
app = typer.Typer()
@app.command()
def greet(name: str):
typer.echo(f"Hello, {name}!")
if __name__ == "__main__":
app()
Working with dates and times just got a whole lot easier with dateutil. This library offers extensive functionality for parsing and manipulating dates and times, surpassing Python's built-in datetime module.
Example:
from dateutil import parser
date_string = "2023-09-30T15:30:00"
parsed_date = parser.parse(date_string)
print(parsed_date)
Visualizing the progress of tasks within loops is a breeze with tqdm. Say goodbye to boring print statements and hello to elegant progress bars that keep you informed.
Example:
from tqdm import tqdm
import time
for i in tqdm(range(100)):
time.sleep(0.1) # Simulate some work
If you love working with Pandas DataFrames and SQL, pandasql is your perfect match. It seamlessly integrates SQL queries with Pandas DataFrames, allowing you to leverage your SQL skills for data manipulation.
Example:
import pandas as pd
from pandasql import sqldf
df = pd.DataFrame({'A': [1, 2, 3], 'B': [4, 5, 6]})
pysqldf = sqldf()
result = pysqldf("SELECT * FROM df WHERE A > 1")
print(result)
TinyDB is a small but mighty NoSQL database that's perfect for small to medium-sized projects. It's easy to use and doesn't require a separate server, making it a versatile choice.
Example:
from tinydb import TinyDB, Query
db = TinyDB('my_db.json')
db.insert({'name': 'Alice', 'age': 30})
db.insert({'name': 'Bob', 'age': 25})
User = Query()
result = db.search(User.name == 'Alice')
print(result)
Unidecode comes to the rescue when you need to transliterate Unicode text into ASCII characters. It simplifies text normalization and handling non-ASCII characters.
Example:
from unidecode import unidecode
text = "Tōkyō"
ascii_text = unidecode(text)
print(ascii_text) # Output: "Tokyo"
Tablib simplifies the handling of tabular data formats like Excel, CSV, and JSON. It's a versatile library that can save you time when dealing with diverse data sources.
Example:
import tablib
data = tablib.Dataset()
data.headers = ['Name', 'Age']
data.append(['Alice', 28])
data.append(['Bob', 35])
# Export to Excel
with open('data.xlsx', 'wb') as f:
f.write(data.export('xlsx'))
Psutil provides a wealth of information about system utilization, allowing you to monitor processes and manage system resources efficiently.
Example:
import psutil
# Get CPU usage
cpu_usage = psutil.cpu_percent()
print(f'CPU Usage: {cpu_usage}%')
# List running processes
processes = psutil.process_iter(attrs=['pid', 'name'])
for process in processes:
print(process.info())
APScheduler empowers you to schedule Python functions to run at specific intervals or times. It's a handy tool for automating repetitive tasks.
Example:
from apscheduler.schedulers.blocking import BlockingScheduler
def job_to_run():
print("Scheduled job ran!")
scheduler = BlockingScheduler()
scheduler.add_job(job_to_run, 'interval', seconds=10)
scheduler.start()
Docx2txt is a valuable library for extracting text content from Microsoft Word (DOCX) files. It's particularly useful for document analysis and data extraction.
Example:
from docx2txt import process
text = process("document.docx")
print(text)
Pyperclip simplifies clipboard operations in Python, making it easy to copy and paste text across different applications and platforms.
Example:
import pyperclip
# Copy text to clipboard
pyperclip.copy("This text is copied to the clipboard")
# Paste text from clipboard
clipboard_text = pyperclip.paste()
print(clipboard_text)
Mtranslate is a powerful library for multilingual text translation. It offers quick and easy translation capabilities to multiple languages using various translation services, making it an asset for globalized applications.
Example:
from mtranslate import translate
text = "Hello, World!"
translated_text = translate(text, 'es') # Translate to Spanish
print(translated_text)
Simpy is a discrete event simulation library that's invaluable for modeling and simulating complex systems, such as traffic flow, supply chains, or resource allocation scenarios.
Example:
import simpy
def car(env):
while True:
print(f"Car at {env.now}")
yield env.timeout(2)
env = simpy.Environment()
env.process(car(env))
env.run(until=10)
Phonenumbers simplifies phone number parsing, formatting, and validation. It's an essential tool for applications dealing with international phone numbers.
Example:
import phonenumbers
phone_number = phonenumbers.parse("+1 650-253-0000", None)
formatted_number = phonenumbers.format_number(phone_number, phonenumbers.PhoneNumberFormat.E164)
print(formatted_number)
Isort takes care of sorting and formatting your import statements in Python code. It ensures consistency and readability in your codebase.
Example:
# Before running isort
from datetime import date
import os
# After running isort
import os
from datetime import date
The emoji library simplifies working with emojis in Python, making it easy to insert emojis into strings or analyze emoji usage in text.
Example:
import emoji
text = "I love Python! :snake:"
emoji_text = emoji.emojize(text)
print(emoji_text)
Pydub is a versatile library for audio processing in Python. It can be used for tasks like audio format conversion, slicing, and more.
Example:
from pydub import AudioSegment
sound = AudioSegment.from_file("my_audio.mp3")
# Convert to WAV format
sound.export("output.wav", format="wav")
Textract is a handy library for extracting text content from a wide range of file formats, including PDFs, Word documents, and more.
Example:
import textract
text = textract.process("document.pdf")
print(text.decode("utf-8"))
PDFMiner is an underrated PDF parsing library that allows you to extract text and metadata from PDF files. It's highly customizable and useful for data extraction.
Example:
from pdfminer.high_level import extract_text
text = extract_text("document.pdf")
print(text)
Pytube simplifies working with YouTube data and videos. It allows you to download, manipulate, or extract information from YouTube videos.
Example (Downloading a YouTube video):
from pytube import YouTube
url = "https://www.youtube.com/watch?v=example_video_id"
yt = YouTube(url)
stream = yt.streams.get_highest_resolution()
stream.download(output_path="downloads/")
By incorporating these lesser-known Python libraries into your toolkit, you'll not only simplify your daily work but also expand your capabilities as a Python programmer. So, embrace these hidden gems, explore their potential, and let them enhance your Python development journey.
Thank you for joining us on this exploration of unsung Python libraries, and we hope you find these tools useful in your coding endeavour.
That concludes our article on unsung Python libraries! We hope you've discovered valuable tools to enhance your daily coding tasks. If you have any more questions or need further guidance, feel free to ask. Happy coding!