Issue
I'm trying to read csv file stored in my computer using pandas. This is my code, but I have a problem like the screenshot.
file_path = "/Users/shazelpark/laptop_pricing_dataset_mod1.csv"
df = pd.read_csv(file_path, header=0)
I'd like to read the file without problem. Please share your solutions.
Thanks
Solution
Try like this
import pandas as pd
file_path = "/Users/shazelpark/laptop_pricing_dataset_mod1.csv"
try:
df = pd.read_csv(file_path, header=0)
print(df.head())
except FileNotFoundError:
print("File not found. Please check the file path.")
except pd.errors.EmptyDataError:
print("The file appears to be empty.")
except pd.errors.ParserError:
print("There was an issue parsing the file. Please check the file format.")
Answered By - Mahboob Nur
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.