I
I
Ivan_ff2018-03-25 18:39:58
Python
Ivan_ff, 2018-03-25 18:39:58

FileNotFoundError in python. How to fix?

I participate in the competition and at step 1 you just need to open and download, but already here it gives an error. I renamed the file both in the program and on the computer, I put the files that need to be imported into the folder with anacode, what's the problem?
from IPython.display import display

import pandas as pd
import matplotlib.pyplot as plt
import sklearn
plt.style.use('ggplot')

x = pd.read_csv('data/train.csv', index_col=0)
y = pd.read_csv('data/target.csv', index_col=0)['radiant_won']

-------------------------------------------------- -------------------------
FileNotFoundError Traceback (most recent call last)
in ()
----> 1 x = pd.read_csv('data /train.csv.csv', index_col=0)
2 y = pd.read_csv('data/target.csv', index_col=0)['radiant_won']
C:\ProgramData\Anaconda3\lib\site-packages\pandas\io\parsers.py in parser_f(filepath_or_buffer, sep, delimiter, header, names, index_col, usecols, squeeze, prefix, mangle_dupe_cols, dtype, engine, converters, true_values , false_values, skipinitialspace, skiprows, nrows, na_values, keep_default_na, na_filter, verbose, skip_blank_lines, parse_dates, infer_datetime_format, keep_date_col, date_parser, dayfirst, iterator, chunksize, compression, thousands, decimal, lineterminator, quotechar, quoting, escapechar, comment, encoding , dialect, tupleize_cols, error_bad_lines, warn_bad_lines, skipfooter, skip_footer, doublequote, delim_whitespace, as_recarray, compact_ints, use_unsigned, low_memory, buffer_lines, memory_map, float_precision)
707 skip_blank_lines=skip_blank_lines)
708
--> 709 return _read(filepath_or_buffer, kwds)
710
711 parser_f.__name__ = name
C:\ProgramData\Anaconda3\lib\site-packages\pandas\io\parsers.py in _read(filepath_or_buffer, kwds)
447
448 # Create the parser.
--> 449 parser = TextFileReader(filepath_or_buffer, **kwds)
450
451 if chunksize or iterator:
C:\ProgramData\Anaconda3\lib\site-packages\pandas\io\parsers.py in __init__(self, f, engine, **kwds)
816 self.options['has_index_names'] = kwds['has_index_names']
817
--> 818 self._make_engine(self.engine)
819
820 def close(self):
C:\ProgramData\Anaconda3\lib\site-packages\pandas\io\parsers.py in _make_engine(self, engine)
1047 def _make_engine(self, engine='c'):
1048 if engine == 'c':
- > 1049 self._engine = CParserWrapper(self.f, **self.options)
1050 else:
1051 if engine == 'python':
C:\ProgramData\Anaconda3\lib\site-packages\pandas\io\parsers.py in __init__(self, src, **kwds)
1693 kwds['allow_leading_cols'] = self.index_col is not False
1694
-> 1695 self._reader = parsers.TextReader(src, **kwds)
1696
1697 # XXX
pandas/_libs /parsers.pyx in pandas._libs.parsers.TextReader.__cinit__()
pandas/_libs/parsers.pyx in pandas._libs.parsers.TextReader._setup_parser_source()
FileNotFoundError: File b'data/train.csv.csv' does not exist

Answer the question

In order to leave comments, you need to log in

3 answer(s)
W
wicker, 2018-03-25
@wicker

put the file in the folder where the running ipython notebook is and call only by the file name

D
Dimonchik, 2018-03-25
@dimonchik2013

os.path.join ( goal_dir, filename)
the path to the target directory will save you - either define or prescribe from the root

A
Alexey Sergeev, 2018-03-26
@SergeevAI

Does the file name bother you in the error? File b'data/train.csv.csv' does not exist

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question