Finding the Largest File in a Directory Using Python

Atharva Shah
Updated on 21-Aug-2023 16:32:05

1K+ Views

Finding the largest file may be helpful in a number of circumstances, including locating the biggest files on a hard drive to make room for smaller ones or examining the size distribution of files in a directory. The biggest file in a directory may be found using a Python script, which will be covered in this article. Algorithm Import the os module. Define a function called find_largest_file that takes a directory as input. Initialize a variable called largest_file to None and a variable called largest_size to 0. Use os.walk to traverse the directory tree recursively, starting from the root ... Read More

Find the K Smallest Values of a NumPy Array

Atharva Shah
Updated on 21-Aug-2023 16:29:49

713 Views

Finding the k smallest values of a NumPy arra Installation and Syntax Pip, Python's package installer, is often used to install NumPy. pip install numpy The following function may be used to identify the k NumPy array elements with the smallest values − np.sort(array)[:k] This returns the first k items of the sorted array after sorting it in ascending order. The array may be be sorted using the alternative syntax shown below, which will retrieve the last k entries and sort the array in descending order − np.sort(array)[::-1][:k] Algorithm The algorithm for finding the k smallest ... Read More

Finding Duplicate Files with Python

Atharva Shah
Updated on 21-Aug-2023 16:28:01

2K+ Views

Copy documents, which consume additional room on the hard drive as we assemble information on our PC, are a commonplace event and therefore, finding and removing duplicate files manually can be time-consuming and tiresome; Thankfully, we are able to automate this procedure with Python so in this lesson we will take a look at exactly how to do that with a short script. Setup For this tutorial, we'll use the built-in os and hashlib modules in Python, so no additional packages need to be installed. import os import hashlib Algorithm Compose a function called hashfile() that utilizes the ... Read More

Finding Difference Between Images Using PIL

Atharva Shah
Updated on 21-Aug-2023 16:26:58

3K+ Views

In image processing, finding the difference between two images is a crucial step in various applications. It is essential to understand the difference between the two images, which can help us in detecting changes, identifying objects, and other related applications. In this blog, we will explore how to find the difference between two images using the Python Imaging Library (PIL). Installation and Syntax To use PIL, we need to install it using the pip package manager. We can install PIL by running the following command in the terminal − pip install pillow To find the difference between two images ... Read More

Convert Array of Objects to Object of Arrays in JavaScript

Sakshi Jain
Updated on 21-Aug-2023 16:20:00

511 Views

The problem statement says to perform a complete conversion of array of objects into an object of arrays in JavaScript where array of objects are given as an input source by the user and given input can be totally converted into the resultant object of arrays successfully. What is an array in JavaScript ? If you are familiar with any other programming language like C, C++, or Java, you must have heard the term 'array.' In programming, an array is a collection of similar data elements under one roof. Now, an important question arises: if arrays are generally the ... Read More

Find Unique Rows in a NumPy Array

Atharva Shah
Updated on 21-Aug-2023 16:13:53

1K+ Views

Duplicate rows in a dataset must frequently be found and removed in data science and machine learning and to solve this issue, a well-liked Python toolkit for numerical computation called NumPy offers a number of methods for manipulating arrays. In this tutorial, we'll go through how to use Python to locate unique rows in a NumPy array. Installation and Setup NumPy must first be installed using pip before it can be used in Python. pip install numpy Once installed, we can import the NumPy library in Python using the following statement − import numpy as np Syntax The ... Read More

Find the Union of Two NumPy Arrays

Atharva Shah
Updated on 21-Aug-2023 16:12:37

476 Views

NumPy is a popular Python library that provides support for numerical computations. It is widely used for array and matrix operations in scientific computing, data analysis, and machine learning. One of the most common tasks in NumPy is finding the union of two arrays. A new array that contains all the distinct elements from both arrays is created when two arrays are joined. In this article, we will explore different ways to find the union of two NumPy arrays. Installation and Syntax NumPy is usually installed with Anaconda or Miniconda distribution. If you don't have it installed, you can install ... Read More

Find Title Tags from HTML Document Using BeautifulSoup in Python

Atharva Shah
Updated on 21-Aug-2023 16:11:33

1K+ Views

A common method for extracting data from web pages is known as web scraping, and the potent Python package BeautifulSoup makes it simple to do so. In this post, we'll concentrate on utilizing Python's BeautifulSoup to extract title tags from a given HTML text. Installation and Syntax Make sure BeautifulSoup is set up on your machine before you start writing any code, this can be done via the Python package installer, pip by typing out the command in your terminal. pip install beautifulsoup4 We must first build a BeautifulSoup object by supplying the HTML content or file to ... Read More

Find Text of a Given Tag Using BeautifulSoup

Atharva Shah
Updated on 21-Aug-2023 16:10:10

5K+ Views

BeautifulSoup is a powerful tool that makes it easy to extract information from HTML and XML documents primarily developed in Python for the purpose of web scraping and web data extraction. One of the most useful features of BeautifulSoup is the ability to find specific tags within a document. In this blog, we will explore how to use BeautifulSoup to find the text of a given tag along with a few examples. Installation and Syntax Installing BeautifulSoup is necessary before using it so use the Python package manager and run the following command right inside your terminal. pip install beautifulsoup4 ... Read More

Count Unique and Distinct Values from a List of Column

Pradeep Kumar
Updated on 21-Aug-2023 15:58:54

212 Views

Excel is a strong tool with a variety of functions to manage data effectively. Finding the number of unique and different values in a column or list of columns is a common task when working with data. For procedures like data analysis, reporting, and decision-making, this information is frequently essential. In this article, we'll look at a number of techniques for counting the amount of distinct and unique variables in Excel. This manual will give you step-by-step directions to help you get precise results whether you're a novice or an expert user. Count the Number of Unique and Distinct Values ... Read More

Advertisements