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
For Ex. Documents can be opened and read through Word Processing software such as MS Word, OO Writer, Word Star, etc.
Need for a data file
- 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
- Creation of files
- Opening files
- Reading files
- Writing files
- Appending data in files
- Deleting Data from files
- Creating copyÂ
- Updating files data
Have a look at text files for Comprehensive Notes on file handling python notes class 12.Â
Text Files
- file_name:Â It accepts a file name with .txt extension.
- access_mode: It specifies the mode to access the file. The default mode is reading mode. These modes are a) r: to read a file     b) w: to write       c) a: append  contents
In the next section of Comprehensive Notes on file handling python notes class 12 you will learn how to read the data from text file.Â
Reading file
Reading n no. of characters |
Using readline() function in python |
Reading whole file using readline() function |
Reading whole file using readlines() function |
Reading a specific line from the text file |
In the next section of Comprehensive Notes on file handling python notes class 12, you will learn how to write data into tex files.Â
Writing to File
Using write() function |
Writing in text file using writelines() function |
Manipulation of Data
Program to count no. of lowercase characters from text file |
Counting words from text file |
A program to print lines starting with ‘S’ |
Program to search occurrences of a word from text files |
tell() and seek()
Download the file
So I hope you enjoyed the article – Comprehensive Notes on file handling python notes class 12 and learn something from it.
Share this article Comprehensive Notes on file handling python notes class 12 with your friends and hit the like button. If you have any doubt or query, you are free to ask in the comment section.
Download the file as pdf from below given link.
Great and worth appreciable work. Good source for begginers to understand a lot more.
#Pythogen
Very nicely explained. Great efforts
A wow work
Thanks, motivate us by visiting and sharing with maximum needy pupils
Thanks for the appreciation, keep visiting and share with maximum
Thanks keep visiting and share
Nice explanation of topics with example
Pingback: Importing/Exporting Data between CSV files and Dataframes - TutorialAICSIP
Pingback: Class 12 Important Questions - File Handling - Computer Science with Python - TutorialAICSIP
great effort
Thanks