Home > Mobile >  Python: FileNotFound Error. No such file or directory
Python: FileNotFound Error. No such file or directory

Time:11-05

I'm writing a program in which Python is unable to read my file despite of me posting the absolute file path with Pandas. The weirdest part is that this program has worked before but it just doesn't now, and I can't get to the bottom of why. Here is the program and error:

import pandas as pd

df = pd.read_csv(r"C:\Users\user\Desktop\Small_businesses1",encoding='latin1')

Error:

FileNotFoundError: [Errno 2] No such file or directory: 'C:\\Users\\user\\Desktop\\Small_businesses1'

The file is for sure at that very location, I copy pasted the location! Any fixes will be greatly appreciated

CodePudding user response:

it seems that you have omitted the file type suffix try

df = pd.read_csv(r"C:\Users\user\Desktop\Small_businesses1.csv",encoding='latin1')
  • Related