Lecture 7 : File Input/Output in Python

Поделиться
HTML-код
  • Опубликовано: 30 сен 2024
  • This lecture was made with a lot of love❤️
    Notes : drive.google.c...
    ✨ Instagram : / shradhakhapra
    ✨ LinkedIn : / shradha-khapra

Комментарии • 343

  • @premsharma2595
    @premsharma2595 2 месяца назад +32

    00:01 Today we will cover Chapter Seven about file operations.
    02:07 RAM is volatile memory and not suitable for permanent storage
    06:02 Using physical files in day-to-day operations
    08:25 Opening a file in read mode returns a text IO wrapper
    13:18 Understanding file reading modes
    15:23 Reading a file and printing its contents
    19:13 Appending data to a file in A mode
    21:17 Differences between different modes
    25:09 Different file modes in Python: Read Plus, Write Plus, Append Plus
    27:19 Using the 'with' syntax in Python automatically closes the file
    31:48 We can delete any file by using the remove function in the os module.
    34:24 Replace Java with Python in a file using the replace method.
    38:59 Write a function to find the line number of the word 'learning' in a file.
    41:02 The code checks if a word exists within a given data string and prints the line number if it does.
    45:28 Extract individual numbers from a string and convert them to integers
    47:20 The code splits a string of numbers separated by commas and prints them individually.

  • @ayushyadavone
    @ayushyadavone 7 месяцев назад +126

    Shradha di please cover all the Topics from 0 to 100 and please start DSA with Python 🙏

    • @neonblade209
      @neonblade209 5 месяцев назад +9

      better to start DSA with Java or c++, becoz u will get more resources in java and c++ , dont start DSA with python

    • @KumarHarsh-qu3fk
      @KumarHarsh-qu3fk 4 месяца назад +6

      @@neonblade209 AI and machine learning is better un python i guess

    • @kapilprajapat-qb6cz
      @kapilprajapat-qb6cz 4 месяца назад +3

      @@KumarHarsh-qu3fk you're right

    • @PythonProjectssss
      @PythonProjectssss 4 месяца назад +4

      @@neonblade209 I want to learn machine learning thats why I chose python so there is any way you can tell where I can learn DSA because leetcode and all other platforms doesnt start from basic It would be great help if you help me with this

    • @UnboxedGoodies
      @UnboxedGoodies 3 месяца назад

      @@PythonProjectssss search for codebasics DSA playlist

  • @divyanshisaluja3133
    @divyanshisaluja3133 3 месяца назад +8

    Ma'am, The vs code is showing empty lines in output even when using the read() function for the first time. what's the reason for this?

    • @educentre6822
      @educentre6822 29 дней назад +2

      bro save your previous txt file, then it will show output.

  • @codewithme1042
    @codewithme1042 7 месяцев назад +29

    please create a series for AI, ML && Neutral Networks and cover all the topics.

  • @RajzMANISH
    @RajzMANISH 7 месяцев назад +40

    I'm waiting = 8th video 🧑‍💻🧑‍💻

    • @vigneshkrishnan424
      @vigneshkrishnan424 7 месяцев назад +9

      I'm waiting = 8th video🧑‍💻🧑‍💻
      ^
      SyntaxError: unterminated string literal (detected at line 1)

    • @mohiteshanshu2555
      @mohiteshanshu2555 6 месяцев назад

      ​@@vigneshkrishnan424😂

    • @Belovedme-1
      @Belovedme-1 Месяц назад

      😂​@@vigneshkrishnan424

  • @Hello-qf2mo
    @Hello-qf2mo 4 месяца назад +6

    Ending nai samjha

  • @Aryan8650
    @Aryan8650 2 месяца назад +2

    Maza tho bhut aaya pr Samajh nhi aaya kuch bhee

  • @irfatali4477
    @irfatali4477 7 месяцев назад +6

    I am from Pakistan and i am learning frontend development by watching your tutorial. you are doing absolutely great work. html css js ho gae ab react.js ka course kab aey ga

  • @ahanabanerjee7138
    @ahanabanerjee7138 2 месяца назад +2

    its not working!!!

  • @kritikapandit3279
    @kritikapandit3279 2 месяца назад +2

    For me this class is not running on VS code,
    but working on Jupyter.
    why is it so.

  • @ccydzggzh
    @ccydzggzh 4 месяца назад +2

    some pls help me when i write replace at 36:20 it is showing
    new_data = data.replace("Java", "Python")
    ^^^^^^^^^^^^
    AttributeError: 'builtin_function_or_method' object has no attribute 'replace'
    pls help me

  • @TUFFANGAMING15
    @TUFFANGAMING15 5 месяцев назад +2

    Hey can anyone tell me why my data is not able to print in new file..Plzzzz

  • @Lavanya-b2m
    @Lavanya-b2m 2 месяца назад +6

    10:24
    mam string is not printing only the type is printing

    • @RahulSingh-ml9hg
      @RahulSingh-ml9hg Месяц назад +1

      same problem with me

    • @BowlNest
      @BowlNest 24 дня назад

      same problem with me

    • @valltakegaming6854
      @valltakegaming6854 22 дня назад

      bhai log
      minimize kar ke karne ke bad ho raha hai
      with every change in demo.txt
      i ahve to Minimize VSC

    • @valltakegaming6854
      @valltakegaming6854 22 дня назад

      @@BowlNest bhai log
      minimize kar ke karne ke bad ho raha hai
      with every change in demo.txt
      i ahve to Minimize VSC

    • @valltakegaming6854
      @valltakegaming6854 22 дня назад

      @@RahulSingh-ml9hg bhai log
      minimize kar ke karne ke bad ho raha hai
      with every change in demo.txt
      i ahve to Minimize VSC

  • @CodeSeriesWithRudra
    @CodeSeriesWithRudra 7 месяцев назад +3

    I am the 1st viewer of this video

  • @Rajput1678
    @Rajput1678 7 месяцев назад +12

    Ma'am please cover projects in this python series as you did in JS series please ❤❤❤

  • @GAMIDATA
    @GAMIDATA 3 месяца назад +1

    Ma'am if I run the "write command in VScode " it is not working. What should I do?
    Pls help... when I run the write command the text in the txt file is not overwriting as you said.... the text remains the same. Pls help..... 🙏🏽🙏🏽

  • @DhritiYadav-iy4cv
    @DhritiYadav-iy4cv 9 дней назад

    We love your classes,
    Please make video lecture on pygame development 😢
    Its our request
    Vote for lectures on pygame
    👇

  • @educentre6822
    @educentre6822 29 дней назад

    my statement automatically showed up on next line, without mentioning "
    ", reason?? (19:55)

  • @davilmaster5001
    @davilmaster5001 3 месяца назад +1

    plz provide the "stack overflow" link

  • @bibekyadav9675
    @bibekyadav9675 17 дней назад

    f= open("demo.txt","r")
    text = f.read()
    line1 = f.readline()
    print(line1)
    print(text)
    print(type(text))
    f.close
    print(text) & print(line1) kiyu output nahi de raha hai mujhme,,, 2 line blank hoke sidha type(text) print ho raha hai

  • @fahimanwari3699
    @fahimanwari3699 10 дней назад

    why do you not speak in English language so every one can understand you better

  • @akhileshghatate4157
    @akhileshghatate4157 2 месяца назад +8

    36:42
    def replace(old_string, new_string):
    with open("practice2.txt","r") as f:
    data=f.read()

    n_data = data.replace(old_string, new_string)
    print(n_data)
    with open("practice2.txt","w") as f:
    f.write(n_data)
    replace("Java","Python")

    • @MKJmahi7876
      @MKJmahi7876 20 дней назад

      def replace("Java" , "python"):
      with open ("practice2.txt", "r" ) as f :
      date= f.read()
      n_data= data.replace("Java" , "python" )
      print(n_data)
      with open("practice2.txt", "w"):
      f.write(n_data)

  • @threelamp1374
    @threelamp1374 7 месяцев назад +1

    di aapka wo kamra dekhna hai, jahan aap baith k padhati hain hamien...

  • @kapil_Jadhav
    @kapil_Jadhav 7 месяцев назад +1

    I'm in 11th is there any option to make money after learning python? I really need money?

  • @namratamankar9138
    @namratamankar9138 4 месяца назад +2

    mam , while replacing the word java to python , and after that the file should be overwritten, but when i was writing the code the file is not being overwritten but the new file is being created , which should not happen right?how should i come over this error.

  • @jalaramstudio
    @jalaramstudio 7 месяцев назад +2

    Please made playlist of advance java concepts

  • @fawziaabdullah197
    @fawziaabdullah197 Месяц назад

    What is a 'stream;? Can anyone help me to understand stream in python?

  • @VANHJAIN
    @VANHJAIN 18 дней назад +1

    binary files ?????? heloooowwww

    • @GuruPrasad-is5pu
      @GuruPrasad-is5pu 12 дней назад

      It's nothing but our data in that file will be stored as 0 and 1

  • @abdullahbut15
    @abdullahbut15 25 дней назад +1

    Mam! this line is very motivational for me that you mentioned in start that "All power is within you you can do anything and everything"

  • @KanzaIltaf
    @KanzaIltaf 22 дня назад +1

    The r+ does not always add the data at the beginning. its totally depends where the cursor is like if we use the read command and then write so in this case after reading data the cursor will be in the end and if then we use the write command then the new data will be added to the end of file: For example in this case: f = open("test.txt" , "r+")
    content = f.read()
    f.write("john" )
    f.close() : now in this case "john" will be added to the end of file. so remember the cursor is not always in the beginning in r+ mode its totally depends what you have done before that line of code. Happy coding😊

  • @CodeClips-CC
    @CodeClips-CC 7 дней назад

    what to do if i have to read only second line of the file and not first one?

  • @rahulkumarbairwa7381
    @rahulkumarbairwa7381 7 месяцев назад +1

    React js course lao❤❤❤❤ a to z consept in react js

  • @omshubhgupta277
    @omshubhgupta277 4 месяца назад +1

    why you don 't made video on exceptional handling, NumPy and the other topic

  • @maniverma8867
    @maniverma8867 7 месяцев назад +1

    First 🥇 like and comment and viewer

  • @harshiljana3701
    @harshiljana3701 29 дней назад +1

    I didn't understand 38:00 where she writes "!= -1". Can someone explain.

  • @Rathore2305
    @Rathore2305 7 месяцев назад +2

    Please di API or Libraries bhi pada Dena 🙏

  • @UjjwalModgill
    @UjjwalModgill Месяц назад +1

    38:35 where the fuc* did that -1 came from?

    • @mahesha1770
      @mahesha1770 5 часов назад

      same, whats that -1

    • @mahesha1770
      @mahesha1770 5 часов назад

      -1 ke bina bhi print ho rahi hai

  • @mahendrakumar5194
    @mahendrakumar5194 4 месяца назад +1

    its gangadhar not vidyadhar😂

  • @trishakarmakar4605
    @trishakarmakar4605 3 месяца назад +1

    it will be great for students if you start DSA with Python...

  • @Successthoughts01
    @Successthoughts01 7 месяцев назад +13

    Thanks didi from bottom of my heart for this awasome python series.

  • @anishbihariofficial9633
    @anishbihariofficial9633 7 месяцев назад

    DSA course in python upload lecture

  • @S.Mishra9913
    @S.Mishra9913 3 месяца назад +1

    Construct a program which accepts a sequence of words separated by whitespace as file input. Print the words composed of digits only.

  • @devanshsingh7097
    @devanshsingh7097 3 месяца назад

    10:26 f = open("demo.txt","r")
    ^^^^^^^^^^^^^^^^^^^^
    FileNotFoundError: [Errno 2] No such file or directory: 'demo.txt'
    plz help me

  • @Gulfam-o7k
    @Gulfam-o7k 7 месяцев назад

    Didi iss course ke baad DSA start kerna

  • @Shehzadhacker
    @Shehzadhacker 7 месяцев назад +2

    What is file text bold,underlines

  • @PreetiPatil-y6p
    @PreetiPatil-y6p 7 месяцев назад +6

    Hi shradha...can you please teach us machine learning??

  • @thegodevil3703
    @thegodevil3703 12 дней назад

    def check_word (n):
    with open ("practice.txt","r") as f:
    data = f.read()
    if (data.find(n) != -1):
    print ("yes data find at -",(data.find(n)))
    else:
    print ("no")

  • @kumkumchaudhary2234
    @kumkumchaudhary2234 3 месяца назад

    Di please upload DSA with python

  • @aleezasoomro6155
    @aleezasoomro6155 13 дней назад

    Ma’am, plz make a playlist for NLP!
    No credible information for NLP and computational linguistics.

  • @NitinSharma-np6tm
    @NitinSharma-np6tm 7 дней назад

    Shaktiman is gangadhar not vidhyadhar ma'am😂 @28:20

  • @praveenshankargouda
    @praveenshankargouda Месяц назад

    f= open("E:\\pythonProject\\Revision Class\\demo.txt", "r")
    data = f.read()
    print(data)
    this code isn't working in my vs code if anybody knows then please do let me know

  • @ApurvaChandanshive
    @ApurvaChandanshive 14 дней назад +1

    Thank you so much didi. ❤

  • @bhavyajeetsinghdevda9651
    @bhavyajeetsinghdevda9651 2 месяца назад

    even though i created demo file in same folder still i am getting error 'demo.txt' file is not created
    i am using vs code can anyone help please
    and if i am giving full path then the error comes is
    SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 2-3: truncated \UXXXXXXXX escape
    please help if any one know the reason

  • @thegodevil3703
    @thegodevil3703 12 дней назад

    def check_for_line (n):
    line_no = 1
    with open("practice.txt", "r") as f:
    for line in f:
    if line.find (n) != -1:
    print (line_no)
    return
    line_no += 1
    return ("not found")
    print(check_for_line("hi"))

  • @parth1240
    @parth1240 7 месяцев назад +1

    Oops concepts Tak hee hai aage bhi karaoge kya python ?

  • @film524serial
    @film524serial 7 месяцев назад

    Mam please c++ language ka video soon come

  • @AbhayNavaneeth
    @AbhayNavaneeth 2 месяца назад

    ileNotFoundError: [Errno 2] No such file or directory: 'demo.txt'

  • @AkankshaRai-p6y
    @AkankshaRai-p6y 2 месяца назад +1

    Hi mam kitna aachha pdhati hai aap thank you so much

  • @MBILAL-g6t
    @MBILAL-g6t 7 месяцев назад +2

    Mam please one shot on react js

  • @dailyuploads3959
    @dailyuploads3959 Месяц назад

    write a program to convert the sequence of number into type of integer
    -----------
    with open('read_num.txt', 'r') as f:
    read_file = f.readline()
    split_stream = read_file.split(",")
    int_converted_val = []
    for num in split_stream:
    number = int(num)
    int_converted_val.append(number)
    print(int_converted_val)

  • @iftekhardanish6529
    @iftekhardanish6529 7 месяцев назад +8

    Ham sab se pahle dekh rahe hoge 😅

  • @asdfgadf-wq6mk
    @asdfgadf-wq6mk 7 месяцев назад +1

    python libraries course

  • @ShashankBrovlogs
    @ShashankBrovlogs 5 месяцев назад

    di gangadhar hi sktiman h na ki vidhyaydhar 😁.

  • @Honey-sj7jz
    @Honey-sj7jz 2 месяца назад +1

    Pip is not working in my vscode. What to do ?

    • @AdityaSharma-f1d
      @AdityaSharma-f1d Месяц назад +1

      Try using pip3 or upgrade your pip/pip3 version
      maybe that will help

    • @Honey-sj7jz
      @Honey-sj7jz Месяц назад +1

      @@AdityaSharma-f1d ok, i will. Thanks

  • @AmnaNaseer-001
    @AmnaNaseer-001 7 месяцев назад

    Ma'am please cover type script after python. love from karachi PAKISTAN.

  • @SarithaDevi-mp2cs
    @SarithaDevi-mp2cs 2 месяца назад +1

    Vote for 8th class students

  • @NishantKumar_N
    @NishantKumar_N 7 месяцев назад

    21:10 Didi, Aapne link to diya hi nahi 😊😊

  • @rohitsangole8844
    @rohitsangole8844 5 месяцев назад

    Not able to open the file , it shows NO SUCH File or directory

    • @sushandahal8957
      @sushandahal8957 5 месяцев назад

      Opening in read mode requires the file to be present in your computer system but write mode creates the file for you

  • @Mikey-sc1rs
    @Mikey-sc1rs 7 месяцев назад +1

    Had a little difficulty in understanding recursion previous lecture any tips?

    • @rewatiraman2956
      @rewatiraman2956 7 месяцев назад

      do sirshasan yoga , you will understand, recursion is like a sirshasana.

    • @Gamer_Harsh7572
      @Gamer_Harsh7572 5 месяцев назад

      same man i also face difficulty learning it still i don't undestand it any tips

  • @LuckySoni-dw4lp
    @LuckySoni-dw4lp 7 месяцев назад

    Didi Next session c++ programming k rakho with some interesting project please didi 🥺🥺🥺🥺🙏

  • @prabhatchhatui3992
    @prabhatchhatui3992 6 месяцев назад

    দিদি C++ এর একটা সিরিজ বানান।
    আপনার সমস্ত ভিডিও গুলি খুবই সাহায্যকারী হয়। 😊😊😊

  • @My_Vlogs00012
    @My_Vlogs00012 7 месяцев назад

    Mam please help me to explore dark web

  • @lookyourdimensionbyfh
    @lookyourdimensionbyfh 2 месяца назад

    Please give us Django course

  • @ADITYAJHA-k8l
    @ADITYAJHA-k8l 29 дней назад

    madam in practicle question 1 instead of using
    can we use multiline string quotes(tripple quotes ) as it is provinding the same output

  • @sehaj8512
    @sehaj8512 2 месяца назад

    DSA using python plzz

  • @innayatsingh9483
    @innayatsingh9483 4 месяца назад +1

    Ma'am meri file open nhi ho rhi h. Code bhi sahi h. 10 baar check kiya h. Kya problem ho skta h

    • @gauravsharma76975
      @gauravsharma76975 4 месяца назад

      Brother dhyaan se dkhna file ki directory kaha h and file ki check krna kaha h fir shi hojayega. for example maine jo txt banaya vo python>lecture>txt wale folder me banaya but python use python foldeer me search kr rha h so dhyaan se dkhna

    • @Ashwathama814
      @Ashwathama814 3 месяца назад

      Txt wali file pe ctrl+s karke usse save karo phir ho jayega

  • @neededucation
    @neededucation 7 месяцев назад +1

    Mam mere pass to yeh ha he nhe mtlb jab main aap wala code chala raha hun thonny pe to woh error generate kar raha ha yeh kiyu mane demo.txt he likha tha

  • @delight5186
    @delight5186 6 дней назад

    its very help lectures

  • @AniketBiswas-ab22
    @AniketBiswas-ab22 2 месяца назад

    can you do some python project and upload it in a playlist .So it will be very helpful for us

  • @dailyuploads3959
    @dailyuploads3959 Месяц назад

    WAP to find the word which we find the I/O streamed file
    -------------------
    def fun():
    with open('read_file.txt',"r") as f:
    word = 'dogs'
    data = True
    line = 1
    while data:
    data = f.readline()
    if(word in data):
    print(line)
    return
    line += 1
    fun()

  • @kisanmanila9317
    @kisanmanila9317 4 месяца назад

    Hi Shradha, Can you take some more session this OS related command , As I have to do some monitoring automation in my servers. But not getting proper source of this? Al least can you please provide the source of above OS command ?

  • @naveenchandra1298
    @naveenchandra1298 2 месяца назад

    But Mam in my laptop the file is open automatically but the new file is not open as in your computer show please help to avoid this.

  • @JunedKhan-ot6el
    @JunedKhan-ot6el 3 месяца назад

    Ma’am ye -1 ka kya logic he ye kyu aya yaha 38:03

  • @ENJOYTHEVIDEO-ie5c
    @ENJOYTHEVIDEO-ie5c 5 месяцев назад

    watch video o.25 speed

  • @sehaj8512
    @sehaj8512 2 месяца назад

    Dsa using python pleasee

  • @SamMentors
    @SamMentors 6 месяцев назад

    It would be really more efficient if you provide us all advances topics of pythons.

  • @rohanbajaj3724
    @rohanbajaj3724 2 месяца назад

    can you also pls make something like this for specific libraries like numpy and datetime

  • @sehaj8512
    @sehaj8512 2 месяца назад

    Dsa using python pleaseeeee

  • @AnoopKumar-qj9tt
    @AnoopKumar-qj9tt 2 месяца назад

    If we go with the traditional method, what if the last no after comma is even no. In that case last no will not come in num bcoz there is no comma after that & we can't check even for it
    Ps: last ques of the video

  • @the.ShubhamRaj
    @the.ShubhamRaj 3 месяца назад

    10:24 me jab ye code likh k run krr rha hu tbb bss class 'str' likh k aa rha h baaki demo.txt pe jo maine likha h vo aa hi nhi rha .... can anyone help me out??/

    • @bhaithakur9120
      @bhaithakur9120 3 месяца назад

      Type likh kar chala Bhai
      Thakur_sahab 03_9 per photo send kar

  • @Abbasi-d8r
    @Abbasi-d8r Месяц назад

    Dear. Boring class

  • @manofvideo-lv7bp
    @manofvideo-lv7bp 4 месяца назад

    please make a video on hack a wifi passworh or crash a password
    🤓🤓🤓🤓

  • @ImranAli-k3s8n
    @ImranAli-k3s8n 7 месяцев назад

    Mam pls typescript sekha de please 500k requested to you ke ap learn krwae ❤ from pk

  • @S.K.0001
    @S.K.0001 7 месяцев назад

    What dep. of the sector should anyone go if they had two year gap after btech with no experience,plz give some suggestions for it as u know not everyone gets jobs in college.and should they prepare for cloud,or full stack or data analytics what to do
    Plz guide...or where will be the vaccancy for them as most of the company don't consider them at all...

  • @ansariremsha
    @ansariremsha 7 месяцев назад

    @ShradhaKhapra can you teach us regular expression in python GUI Thread Date and time database management using python

  • @MuhammadTayyab-o3c
    @MuhammadTayyab-o3c 7 месяцев назад

    I will keep commenting untill you make a video on REACT JS.

  • @physicstomystry
    @physicstomystry 7 месяцев назад

    Mam is this also helpful for btech 2nd year Aktu syllabus is this complete and enough to get master upon pythons plz response mam .

  • @thekveer
    @thekveer 3 месяца назад

    hell dii in my window 10 i am not able to run this code..
    i tried several time but its not working
    so plz help me to resolve this problem

    • @Ashwathama814
      @Ashwathama814 3 месяца назад

      Kya problem aa rahi hai?

    • @thekveer
      @thekveer 3 месяца назад

      @@Ashwathama814 code run hi nhi ho raha

  • @bhavishyagupta3881
    @bhavishyagupta3881 7 месяцев назад +5

    mam please aap python with data analysis bhi padha dijiye

  • @ioeentrancepreparation6178
    @ioeentrancepreparation6178 7 месяцев назад