error handling in python | Lec-23

In this video, I have talked about the fundamentals of programming and Python. If you complete this, you will be well-versed in using tuples for different use cases.
Directly connect with me at:- topmate.io/manish_kumar25
Save this data into file:-
id,name,age,gender
1,"Manish",26,"M"
2,"Rohan",13,"M"
3,"Simaran",35,"F"
5,"Manish,26,"M"
4,"Rohan",13,"M"
Discord channel:- / discord
For more queries reach out to me on my below social media handle.
Follow me on LinkedIn:- / manish-kumar-373b86176
Follow Me On Instagram:- / competitive_gyan1
Follow me on Facebook:- / manish12340
My Second Channel -- / @competitivegyan1
Interview series Playlist:- • Interview Questions an...
My Gear:-
Rode Mic:-- amzn.to/3RekC7a
Boya M1 Mic-- amzn.to/3uW0nnn
Wireless Mic:-- amzn.to/3TqLRhE
Tripod1 -- amzn.to/4avjyF4
Tripod2:-- amzn.to/46Y3QPu
camera1:-- amzn.to/3GIQlsE
camera2:-- amzn.to/46X190P
Pentab (Medium size):-- amzn.to/3RgMszQ (Recommended)
Pentab (Small size):-- amzn.to/3RpmIS0
Mobile:-- amzn.to/47Y8oa4 ( Aapko ye bilkul nahi lena hai)
Laptop -- amzn.to/3Ns5Okj
Mouse+keyboard combo -- amzn.to/3Ro6GYl
21-inch Monitor-- amzn.to/3TvCE7E
27-inch Monitor-- amzn.to/47QzXlA
iPad Pencil:-- amzn.to/4aiJxiG
iPad 9th Generation:-- amzn.to/470I11X
Boom Arm/Swing Arm:-- amzn.to/48eH2we
My PC Components:-
intel i7 Processor:-- amzn.to/47Svdfe
G.Skill RAM:-- amzn.to/47VFffI
Samsung SSD:-- amzn.to/3uVSE8W
WD Blue HDD:-- amzn.to/47Y91QY
RTX 3060Ti Graphic card:- amzn.to/3tdLDjn
Gigabyte Motherboard:-- amzn.to/3RFUTGl
O11 Dynamic Cabinet:-- amzn.to/4avkgSK
Liquid cooler:-- amzn.to/472S8mS
Antec Prizm FAN:-- amzn.to/48ey4Pj

Пікірлер: 8

  • @ShubhamRai06
    @ShubhamRai06Ай бұрын

    very well explained.

  • @vishnu000001
    @vishnu0000012 ай бұрын

    Hi Manish, def find_distinct_name(file_path,action): try: file = open(file_path, action) lines = file.read().splitlines() name = [] if len(lines)==0: raise Exception("the file is empty") else: for i in range(1,len(lines)): line = lines[i] words = line.split(",") name.append(words[1]) name_list = set(name) print(name_list) except Exception as e: print(e) find_distinct_name("details.txt", "r") o/p = {'"Manish"', '"Rohan"', '"Simaran"', '"Manish'} when reading the file using read option. All the lines are getting converted into strings and when i use split method to get list from lines. I am getting data as "Manish" and "Manish, instead of error. Please let me know if there is a way to read data from txt file along with data type.

  • @sharadsonwane6594
    @sharadsonwane65942 ай бұрын

    👍

  • @parthmadannn
    @parthmadannn2 ай бұрын

    sir how to practice python for data analyst

  • @bhargavnagineni9322
    @bhargavnagineni93222 ай бұрын

    Hi bro.. can you please share the topics required in python for data engineer

  • @ankitdhurbey7093
    @ankitdhurbey70932 ай бұрын

    import pandas as pd def unique_values(path, column_name): try: df = pd.read_csv(path) name = df[f"{column_name}"] return set(name) except FileNotFoundError: print("The File is not available at given path") raise Exception("Please check the path provided") except KeyError: raise Exception("Please provide the correct column name") except Exception as e: if (str(e) == 'No columns to parse from file'): raiseException('The file is empty, No columns found') try: output = unique_values(path="C:/Desktop/NewFolder/names.csv",column_name="name") except Exception as e: print(e) print(f"The list of unique values are : {list(output)}")

  • @hardeepcharak
    @hardeepcharak2 ай бұрын

    Is that you in DP?

  • @safiadawood5637
    @safiadawood5637Ай бұрын

    import os filename = r'C:\Users\homeuser\Documents\de prjs\Python\manish\user_info.txt' name_list = [] try: if os.path.getsize(filename) == 0: raise Exception("Empty File") else: with open(filename,'r') as handler: # read next line next(handler) # rstrip to remove '/n at end of line, split at , and name is at position 1 for line in handler: name_element = line.rstrip().split(',')[1] if not(name_element.startswith('"') and name_element.endswith('"')): raise ValueError(f"Name is not properly quoted : {name_element}") name_list.append(name_element) print(set(name_list)) handler.close() except FileNotFoundError: print("File cannot be opened: ", filename) except ValueError as e: print(e) except Exception as e: print(e)