In this article Comprehensive Notes on file handling python notes class 12, we will provide you with an introduction to file handling and text files in python.
Introduction to file handling python notes class 12
As we know, Files are an essential part of computers. Everything stored in the computer is saved in files. These files are a collection of bytes stored in computers. Data can be represented in specific forms in files. These files can be accessed at any time. These files are saved with an extension or file types. They need a specific program to read data and write data.
For Ex. Documents can be opened and read through Word Processing software such as MS Word, OO Writer, Word Star, etc.
File handling is the process of handling data by software including IO operations. These files stored in a directory on a hard drive. Whenever any operation is carried out, the file is opened and make available to write upon on reading purposes on RAM.
In the next section, we will discuss what is the need for a data file in the context of the article – Comprehensive Notes on File Handling in Python class 12.
Need for a data file
The computer has a powerful feature of saving data. As you know data means raw facts and figures. and meaningful data is known as information. These data can be stored in a file. Whenever users need such data, data can be presented by files.
When you develop a program in python, the final output of the program is not available for future use. Data files serve this purpose.
They can store the output in the following files and those files we will use in file handling python notes class 12:
Text Files: It has an extension .txt. It can be directly opened by a text editor like notepad, Wordpad, etc. It is capable to handle textual data and information. The text files contain a series of lines. A line is a set of characters or strings. These characters can be in ASCII or UNICODE form. In the text files, each line is terminated by ‘EOL-End Of Line’ i.e ‘/n’ in python.
Binary Files: Binary files are capable to store large files such as images, videos, audio files, etc. These files have a specific pattern to read data in the correct type. These files don’t have any delimiter. They are easier and faster than text files. In binary files data interpreted by correct data type. Python provides specific functions to handles these data types and data files.
CSV (Comma Separated Values) Files: It is a plain text file that contains a list of data. CSV files can be opened and operated by MS Excel and allow to export and import data. It can handle big data. All the values are separated by a comma.
In the next section of Comprehensive Notes on file handling python notes class 12 data file operations are listed out:
Data file operations
The following tasks will be performed on data files.
Creation of files
Appending data in files
Deleting Data from files
Updating files data
Have a look at text files for Comprehensive Notes on file handling python notes class 12.