File exists but Python says 'not found'.

Robert Kern robert.kern at gmail.com
Mon Jul 1 06:56:38 EDT 2013


On 2013-07-01 11:47, prerit86 at gmail.com wrote:
> I'm running this code that reads 2 csv files (one of them is train.csv). The code gives an error saying 'file not does not exist'. However, the file does exists in the same location as the .py file. Can someone please help me on this. Thanks!

How are you running the code? If you are doing pandas.read_csv('train.csv'), the 
file must be in the current working directory of the running process. The 
location of the .py file contain the code is not relevant. For example, if you 
are using an IDE to run the script, you may need to configure how it runs the 
script to pick a particular directory for it to run in.

> Code Output-->
>
> Reading dataset...
> Traceback (most recent call last):
>    File "c:\Project_1\regression_2.py", line 163, in <module>
>      main(**args)
>    File "c:\Project_1\regression_2.py", line 80, in main
>      train_data = pd.read_csv(train)

Since the filename of regression_2.py in the traceback is fully-qualified, I 
expect that you are running the program from something other than the 
c:\Project_1\ directory.

-- 
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless enigma
  that is made terrible by our own mad attempt to interpret it as though it had
  an underlying truth."
   -- Umberto Eco




More information about the Python-list mailing list