Error in Python IOError: [Errno 2] No such file or directory: 'data.csv'

Doug Fir picture Doug Fir · Oct 21, 2012 · Viewed 118.6k times · Source

In Python, I have a script, I'm trying to use the python open("data.csv") command to open a CSV file that I have in the Python script directory.

There is a file there called data.csv.

The python script indicates an error:

Error in Python IOError: [Errno 2] No such file or directory: 'data.csv'

What does this error mean and how do I fix it?

Here is the minimal code in the script that reproduces the error:

open("data.csv")

Answer

Senthil Kumaran picture Senthil Kumaran · Oct 21, 2012

Try to give the full path to your csv file

open('/users/gcameron/Desktop/map/data.csv')

The python process is looking for file in the directory it is running from.