File Not Found Error: Computer can't find an existing file

Viewed 46

I'm trying to read a file in the same folder as my main.py and am getting the following error.

FileNotFoundError: [Errno 2] No such file or directory: 'central_park_census.csv'

Here is my code:

import pandas
all_data = pandas.read_csv("central_park_census.csv")
print(type(all_data))

The issue is that the said file exists and is in the same folder as my main.py. I use the windows OS and this error has been prevalent with text files also. Please help if you can :))

1 Answers

This problem is caused by the path. Vscode identifies the path differently from other ides. Vscode retrieves files using the workspace as the current directory, not the currently opened folder. Therefore, please modify the path according to the workspace.

Related