#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

ความคิดเห็น • 28

  • @UrjaAcademy
    @UrjaAcademy  3 ปีที่แล้ว +14

    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.

  • @kruthikshama133
    @kruthikshama133 ปีที่แล้ว +3

    Excellent teaching keep doing sir for class 12 CBSE computer science

  • @vinamramishra7157
    @vinamramishra7157 2 หลายเดือนก่อน +2

    thank you sir, great explanation

  • @firmwareeme985
    @firmwareeme985 3 ปีที่แล้ว +1

    string data is not being converted in binary....and can be read as it is. e.g."abc".....is not being converted

  • @rajeswarikathiravan2636
    @rajeswarikathiravan2636 3 ปีที่แล้ว +1

    Very helpful thank you so much sir

  • @rgapoorva3070
    @rgapoorva3070 3 ปีที่แล้ว +1

    In 31.17 seconds, I think pickling is done through dump() and unpickling is done through load() , right ?

    • @UrjaAcademy
      @UrjaAcademy  3 ปีที่แล้ว +1

      Yes Apoorva , I made a mistake on that part. Thanks for pointing out.

  • @akilapalanisamy9648
    @akilapalanisamy9648 3 ปีที่แล้ว +1

    In binary files, Can we replace file pointer to some other location other than the beginning of the file using seek()?

    • @UrjaAcademy
      @UrjaAcademy  3 ปีที่แล้ว +1

      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

    • @akilapalanisamy9648
      @akilapalanisamy9648 3 ปีที่แล้ว

      @@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

  • @dipanbitamazumder3831
    @dipanbitamazumder3831 3 ปีที่แล้ว +1

    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?

    • @UrjaAcademy
      @UrjaAcademy  3 ปีที่แล้ว

      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.

    • @dipanbitamazumder3831
      @dipanbitamazumder3831 3 ปีที่แล้ว

      ​@@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?

    • @UrjaAcademy
      @UrjaAcademy  3 ปีที่แล้ว +1

      not like that...your code is fine...After running the tuple when you enter the list put the list within [ ]

  • @higiniofuentes2551
    @higiniofuentes2551 11 หลายเดือนก่อน

    Thank you for this very useful video!

  • @rajasree3861
    @rajasree3861 4 ปีที่แล้ว +1

    sir will u teach standard input,output and error stream in text file and search,append,update in binary file sir

    • @UrjaAcademy
      @UrjaAcademy  4 ปีที่แล้ว

      Yes.

    • @rajasree3861
      @rajasree3861 4 ปีที่แล้ว

      @@UrjaAcademy can i know when will it be uploaded sir it will be useful for my study plan sir

    • @UrjaAcademy
      @UrjaAcademy  4 ปีที่แล้ว

      I am planning to upload within a week if production is complete.

    • @rajasree3861
      @rajasree3861 4 ปีที่แล้ว

      @@UrjaAcademy thank u so much sir

    • @rajasree3861
      @rajasree3861 3 ปีที่แล้ว

      sir u told u will upload it within a week??

  • @oathkeeper2498
    @oathkeeper2498 3 ปีที่แล้ว +2

    Sir have you finished the complete portion of 12th

    • @UrjaAcademy
      @UrjaAcademy  3 ปีที่แล้ว +1

      no 2 chapters left in parts...but i cannot make now

    • @oathkeeper2498
      @oathkeeper2498 3 ปีที่แล้ว +1

      @@UrjaAcademy name of those chapters

    • @UrjaAcademy
      @UrjaAcademy  3 ปีที่แล้ว +1

      Using Python Libraries only....Rest some topics of data structures and some of file handling left

  • @Puh539
    @Puh539 4 ปีที่แล้ว +1

    Thank you sir

  • @rgapoorva3070
    @rgapoorva3070 3 ปีที่แล้ว +1

    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 .

    • @UrjaAcademy
      @UrjaAcademy  3 ปีที่แล้ว

      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