READ FILES using Python! (.txt, .json, .csv) 🔍

Поделиться
HTML-код
  • Опубликовано: 15 янв 2025

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

  • @BroCodez
    @BroCodez  6 месяцев назад +4

    # Python reading files (.txt, .json, .csv)
    # ---------- .txt ----------
    file_path = "C:/Users/HP/Desktop/input.txt"
    try:
    with open(file_path, 'r') as file:
    content = file.read()
    print(content)
    except FileNotFoundError:
    print("That file was not found")
    except PermissionError:
    print("You do not have permission to read that file")
    # ---------- .json ----------
    import json
    file_path = "C:/Users/HP/Desktop/input.json"
    try:
    with open(file_path, 'r') as file:
    content = json.load(file)
    print(content )
    except FileNotFoundError:
    print("That file was not found")
    except PermissionError:
    print("You do not have permission to read that file")
    # ---------- .csv ----------
    import csv
    file_path = "C:/Users/HP/Desktop/input.csv"
    try:
    with open(file_path, 'r') as file:
    content = csv.reader(file)
    for line in content:
    print(line)
    except FileNotFoundError:
    print("That file was not found")
    except PermissionError:
    print("You do not have permission to read that file")

  • @MarcsBianchini
    @MarcsBianchini 6 месяцев назад +2

    You can you use an 'r' in front of the absolute path and let the path unchanged. like this r"C:\User\HP\Descktop".

  • @piano_depois_dos_50
    @piano_depois_dos_50 6 месяцев назад +2

    Thank you.

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

    Very helpful. Thanks, Bro!

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

    Thanks a lot man, it helped me.

  • @Quizzes-n7l
    @Quizzes-n7l 6 месяцев назад +3

    BROCODE IM A BIG BIG FAN, I learned Css and Html from you and am currently learning React.Js. BRO AM A BIG FAN THANKS ALLOT FOR TEACHING ME

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

      same here bro!thank u bro code

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

    Thank you Bro for beautiful content

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

    BIG THANKS TO YOU

  • @pizzalawl3544
    @pizzalawl3544 6 месяцев назад +1

    yo I know you haven't done C videos in a while but could you please do a tutorial on preprocessor directives?? really need a good one right now and i can't find anything good online.

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

    kotlin full course please man !

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

    Brooo i wanna see your C# window tutorial video

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

    Came in clutch i have an exam on this tmr lol

  • @MarianoBustos-i1f
    @MarianoBustos-i1f 6 месяцев назад

    Thanks Bro

  • @robert-qn8hy
    @robert-qn8hy 6 месяцев назад

    Can you please make a video on Lambda Decorators in python... 🙏

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

    When you will teach us the android development bro...♥♥♥♥♥♥♥♥

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

    First