How to Write Huge Amounts of Generated Data to a File in Python?

Problem formulation Sometimes we need to generate massive amounts of data. For example, to perform bootstrapping or jackknifing of our actual data. To get lots of parameterized dummy data, learn how to use new libraries or adjust the model’s hyperparameters. Or benchmark different solutions or debug and optimize our code. Generating this data is expensive, … Read more

Choose A File Starting With A Given String

Overview Problem: How to choose a file starting with a given string? Example: Consider that we have a directory with files as shown below. How will you select the files starting with “001_Jan“? Python Modules Cheat Sheet To Choose A File Starting With A Given String Choosing a file starting with a given string is … Read more

How to Compress PDF Files Using Python?

Problem Formulation Suppose you have a PDF file, but it’s too large and you’d like to compress it (perhaps you want to reduce its size to allow for faster transfer over the internet, or perhaps to save storage space).  Even more challenging, suppose you have multiple PDF files you’d like to compress.  Multiple online options … Read more

Python os.walk() – A Simple Illustrated Guide

According to the Python version 3.10.3 official doc, the os module provides built-in miscellaneous operating system interfaces. We can achieve many operating system dependent functionalities through it. One of the functionalities is to generate the file names in a directory tree through os.walk(). If it sounds great to you, please continue reading, and you will … Read more

PowerShell Developer – Income and Opportunity

Annual Income How much does a Powershell Developer make per year? The average annual income of a Powershell Developer is between $93,000 (25th percentile) and $170,000 (75h percentile) with top earners making $170,000 per year and more according to Ziprecruiter (source): Let’s have a look at the hourly rate of Powershell Developers next! Hourly Rate … Read more

Bash Developer – Income and Opportunity

Annual Income How much does a Bash Developer make per year? The average annual income of a Bash Unix Shell Script Developer is $74,000 according to Ziprecruiter (source). PayScale lists an even higher annual income for a bash developer of $80,000 (source). Let’s have a look at the hourly rate of Bash Developers next! Hourly … Read more

Read from Stdin in Python

[toc] Problem Statement: Reading from stdin in Python. Reading inputs from the user is one of the fundamental building blocks that we learn while learning any programming language. The output of most codes depends on the user’s inputs. Hence, in this article, we are going to learn how to read from stdin in Python. There … Read more

How to List All Files ONLY in the Current Directory?

Problem Formulation How to list all files in the current directory given these constraints: Non-Recursive: You do not want to list files in subdirectories. ONLY Files: You do not want to list folder names. Current Directory: You run the Python script from the current directory. Here’s an example structure: current_folder — code.py — file.txt — … Read more

How to Make a Beep Sound in Python? [Linux/macOS/Win]

Windows: How to Make Beep in Python To make a beep sound in Python on your Windows machine: Import the library using: import winsound Call windsound.Beep(frequency, duration) for your desired frequency (in Hertz) and duration (in milliseconds). For example, winsound.Beep(2000, 1500) would make a sound with 2000 Hz for 1.5 seconds. Here’s the relevant code … Read more