#7 Reading and Writing Into Binary Files in Python | File Handling | Class 12 CBSE Computer Science
ฝัง
- เผยแพร่เมื่อ 24 ก.ย. 2024
- Welcome to the Part 7 of the Chapter Data File Handling in Python for class 12 CBSE Computer Science .
In this video I have discussed how to work with Binary files in Python. In this part the reading and writing data into binary files in python is discussed .
If you haven't watched the other parts of this Chapter , you may watch them by clicking on the links below 👇:
👉 Part 1 Introduction to Data file handling in python
• #1 Introduction to Dat...
👉 Part 2 Introduction to text files in python
• #2 Introduction to Tex...
👉 Part 3 Reading data from text files in python
• #3 Reading Data From T...
👉 Part 4 Writing and appending data into text files in python
• #4 Writing and Appendi...
👉 Part 5 Data Manipulation in text files in python
• #5 Data Manipulation i...
👉 Part 6 Reading and Writing data into csv files in python
• #6 Reading and Writing...
Topics:
Basic concept of Binary files
Opening a Binary file with open()
Binary File Modes in Python
closing a binary file in python with close()
pickle module in python
Functions related to pickle module:
dump() function in python
load() function in python
Concept of pickling and unpickling
Practical program based on reading data from binary files
File Modes for writing and appending data in python
Practical program based on writing data into binary files in python
Practical program based on reading data from binary files in python
Practical program based on writing and reading data into binary files in python
While implementing the practical programs in Python , I have used spyder IDE on MacOS . You can use any other IDE of your choice.
Connect on these social media Handles:
👉 Instagram: / bhargab_kakati
👉 LinkedIn : / bhargabkakati
👉 Twitter : / bhargab008
Bhargab Kakati
PGT(Computer Science)
data file handling in python class 12
reading and writing data into binary files in python
#Python #FileHandling #Class12 #ComputerScience #BinaryFiles
Dear viewers , In 31:08 I made a typing mistake unknowingly regarding the terms picking and unpicking . Pickling is done through dump( ) and unpicking is done through load( ) . You are advised to make necessary corrections while making notes . The programs are correct.
Excellent teaching keep doing sir for class 12 CBSE computer science
thank you sir, great explanation
string data is not being converted in binary....and can be read as it is. e.g."abc".....is not being converted
Very helpful thank you so much sir
In 31.17 seconds, I think pickling is done through dump() and unpickling is done through load() , right ?
Yes Apoorva , I made a mistake on that part. Thanks for pointing out.
In binary files, Can we replace file pointer to some other location other than the beginning of the file using seek()?
Yes Akila, that can be done .. 0 represents the beginning of the file , 1 represents firsr character of file 2 represents second character and so on..Just change the number to yout desired position
@@UrjaAcademy
import pickle
f=open("bfile.dat","wb+")
stud=[]
Count=int(input('enter the no of students"))
for I in range(Count):
rno=int(input("enter rollno'))
name=input("enter the name")
stud=[rno,name]
pickle.dump(stud,f)
f.seek(3)
G=pickle.load(f)
print(G)
f.close()
Could you pl tell me what's wrong with this pgm .. it's shows unpickling error when I'm trying to move FP to specified loc using seek().
TIA
Sir, on entering values and checking the type of the sentence -> l=eval(input("enter list:")) , I got it as a tuple, but you said eval() will give a list, then why am I getting a tuple?
put the input within [ ] . By default if you do not give the brackets , then it takes as a tuple so make sure you give the braces.
@@UrjaAcademy Error is shown if I try to give square[ ] brackets.
# case 1:
x=eval [ input ( "enter list= " ) ]
print(x)
print(type(x))
Output->
enter list= 21,54,654
Traceback (most recent call last):
File "C:\Users\Desktop\binary.py", line 1, in
x=eval [ input ( "enter list= " ) ]
TypeError: 'builtin_function_or_method' object is not subscriptable
#case 2:
x=eval ( input [ "enter list= " ] )
print(x)
print(type(x))
Output->
Traceback (most recent call last):
File "C:\Users\Desktop\binary.py", line 1, in
x=eval ( input [ "enter list= " ] )
TypeError: 'builtin_function_or_method' object is not subscriptable
How to solve the issue?
not like that...your code is fine...After running the tuple when you enter the list put the list within [ ]
Thank you for this very useful video!
sir will u teach standard input,output and error stream in text file and search,append,update in binary file sir
Yes.
@@UrjaAcademy can i know when will it be uploaded sir it will be useful for my study plan sir
I am planning to upload within a week if production is complete.
@@UrjaAcademy thank u so much sir
sir u told u will upload it within a week??
Sir have you finished the complete portion of 12th
no 2 chapters left in parts...but i cannot make now
@@UrjaAcademy name of those chapters
Using Python Libraries only....Rest some topics of data structures and some of file handling left
Thank you sir
Hi sir , thank you so much for these lectures. They are really helpful 😄👍🏻 Please upload the remaining parts sir (mainly in file handling , stacks and queues ) as soon as possible sir , a kind request .
Will try to upload. Due to lack of time and offline classes I am unable to make out the time for the channel. Thanks for the feedback