Shadman Mahmood Shadman Mahmood - 1 year ago 46
Python Question

Python Cannot find file although the error says it exists

I have been trying to load the files in python but somehow I cant do so? any help or suggestions would be really helpful.

import numpy as np
import pandas as pd
print df

Error shown:

File C:/Users/user/Desktop/Work/a.csv does not exist

Answer Source

Seems like you are using windows. Windows directory separator is \ not / try this way:



import os
file_path = os.path.sep.join(["C:", "Users", "user", "Desktop", "Work", "a.csv"])
df = pd.read_csv(file_path)