File exists but Python says 'not found'.

Antoon Pardon antoon.pardon at rece.vub.ac.be
Mon Jul 1 06:59:53 EDT 2013


Op 01-07-13 12:47, prerit86 at gmail.com schreef:
> 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!
>
> 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)
>   File "c:\Python27\lib\site-packages\pandas\io\parsers.py", line 401, in parser
> _f
>     return _read(filepath_or_buffer, kwds)
>   File "c:\Python27\lib\site-packages\pandas\io\parsers.py", line 209, in _read
>     parser = TextFileReader(filepath_or_buffer, **kwds)
>   File "c:\Python27\lib\site-packages\pandas\io\parsers.py", line 509, in __init
> __
>     self._make_engine(self.engine)
>   File "c:\Python27\lib\site-packages\pandas\io\parsers.py", line 611, in _make_
> engine
>     self._engine = CParserWrapper(self.f, **self.options)
>   File "c:\Python27\lib\site-packages\pandas\io\parsers.py", line 893, in __init
> __
>     self._reader = _parser.TextReader(src, **kwds)
>   File "parser.pyx", line 312, in pandas._parser.TextReader.__cinit__ (pandas\sr
> c\parser.c:2846)
>   File "parser.pyx", line 512, in pandas._parser.TextReader._setup_parser_source
>  (pandas\src\parser.c:4893)
> IOError: File train.csv does not exist

My guess is that train.csv is a symbolic link that points to a file
that doesn't exist. So looking at your directory you can see an entry
but actualy trying to open it will fail.

-- 
Antoon Pardon



More information about the Python-list mailing list