Niharikaa Aitam has Published 93 Articles

How are files added to a tar file using Python?

Niharikaa Aitam

Niharikaa Aitam

Updated on 27-May-2025 18:14:57

2K+ Views

Python offers a built-in module named tarfile, which allows developers to create, read, and modify tar archives, i.e., standard Unix tarballs. We can use this module to compress multiple files into a single archive, with or without compression. Different File Modes to Create a tar file Here are the available ... Read More

How to extract a part of the file path (a directory) in Python?

Niharikaa Aitam

Niharikaa Aitam

Updated on 27-May-2025 18:10:57

4K+ Views

In Python, we can extract a specific part of a file path of the directory using built-in modules such os.path and pathlib. Extracting a part of the file path is commonly needed when working with file systems, data processing, or scripts that handle files dynamically. Using os.path Module The os.path ... Read More

How is a file read using a limited buffer size using Python?

Niharikaa Aitam

Niharikaa Aitam

Updated on 27-May-2025 17:54:34

1K+ Views

In Python, when we are working with files that contain a large amount of data then it is often inefficient to read the entire content into memory at once. In such cases, we can read a fixed amount of data at a time by using the read() method with a ... Read More

How to list directory tree structure in python?

Niharikaa Aitam

Niharikaa Aitam

Updated on 27-May-2025 17:48:20

8K+ Views

The given task is to list the directory tree structure, i.e., we need to print the hierarchy of folders and files starting from a specified root directory. This is similar to how the tree command works in Linux or Windows by showing nested folders and files in a structured and ... Read More

How to open new pseudo-terminal pair using Python?

Niharikaa Aitam

Niharikaa Aitam

Updated on 15-May-2025 18:38:47

1K+ Views

Pseudo-terminals (pty) are an advanced and powerful technique in Python when we are dealing with terminal-based processes or simulating interactive sessions programmatically. A pseudo-terminal allows a process to connect to a real terminal. Python provides a built-in pty module that helps in creating and managing these terminal pairs. In ... Read More

How do we specify the buffer size when opening a file in Python?

Niharikaa Aitam

Niharikaa Aitam

Updated on 15-May-2025 18:37:46

9K+ Views

When we open a file using the Python's built-in function open(), then the data temporarily stored in memory can be managed by setting the buffering parameter in the function. Buffering helps to improve the performance of opening a file by reducing the number of interactions with the disk during file ... Read More

What does the \\\\'U\\\\' modifier do when a file is opened using Python?

Niharikaa Aitam

Niharikaa Aitam

Updated on 15-May-2025 18:35:11

1K+ Views

When the U modifier is used while opening a file then Python opens the file in Universal Newline mode. This mode enables Python to automatically detect and handle all common newline characters including , \r and \r during file reading. It is particularly useful when working with text files generated ... Read More

How to find difference between 2 files in Python?

Niharikaa Aitam

Niharikaa Aitam

Updated on 15-May-2025 18:32:09

11K+ Views

In most of the applications, especially in data processing, software development or testing, it is required to compare two files to detect changes, validate outputs or find discrepancies. Python offers several ways to compare files which ranges from basic line-by-line comparisons to more advanced diff utilities. Following are the key ... Read More

How to share common data among multiple Python files?

Niharikaa Aitam

Niharikaa Aitam

Updated on 15-May-2025 18:28:13

2K+ Views

In Python, sharing common data such as constants, configuration settings or shared resources among multiple files is a routine task in modular application development. The data will be centralized in a dedicated module which allows it to be maintained in one place and imported wherever needed. Before proceeding with various ... Read More

How to remove hidden files and folders using Python?

Niharikaa Aitam

Niharikaa Aitam

Updated on 15-May-2025 18:04:57

3K+ Views

Managing hidden files and folders in a directory is an essential part of building cleanup scripts or automation tools. On Windows, hidden files are not prefixed with a dot but instead they are marked using specific file attributes. In this article, we will explore how to remove those hidden files ... Read More

Previous 1 ... 4 5 6 7 8 ... 10 Next
Advertisements