Read file path issue

Discussion in 'Big Data and Analytics' started by mayankchaudhary239, Nov 10, 2018 at 1:15 PM.

  1. mayankchaudhary239

    Alumni

    Joined:
    Apr 14, 2015
    Messages:
    2
    Likes Received:
    0
    While executing the below code i facing the file not found error although i downloaded the respective file
    from google drive.

    # set the path of the raw data
    raw_data_path = os.path.join(os.path.pardir,'data','raw')
    train_file_path = os.path.join(raw_data_path, 'train.csv')
    test_file_path = os.path.join(raw_data_path, 'test.csv')

    # read the data with all default parameters
    train_df = pd.read_csv(train_file_path, index_col='PassengerId')
    test_df = pd.read_csv(test_file_path, index_col='PassengerId')

    Please find below the error -
    FileNotFoundError Traceback (most recent call last)
    <ipython-input-19-061b7317a80e> in <module>()
    ----> 1test_df = pd.read_csv(test_file_path, index_col='PassengerId')

    ~/anaconda3/lib/python3.7/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, doublequote, delim_whitespace, low_memory, memory_map, float_precision)
    676 skip_blank_lines=skip_blank_lines)
    677
    --> 678return _read(filepath_or_buffer, kwds)
    679
    680 parser_f.__name__ = name

    ~/anaconda3/lib/python3.7/site-packages/pandas/io/parsers.py in _read(filepath_or_buffer, kwds)
    438
    439 # Create the parser.
    --> 440parser = TextFileReader(filepath_or_buffer, **kwds)
    441
    442 if chunksize or iterator:

    ~/anaconda3/lib/python3.7/site-packages/pandas/io/parsers.py in __init__(self, f, engine, **kwds)
    785 self.options['has_index_names'] = kwds['has_index_names']
    786
    --> 787self._make_engine(self.engine)
    788
    789 def close(self):

    ~/anaconda3/lib/python3.7/site-packages/pandas/io/parsers.py in _make_engine(self, engine)
    1012 def _make_engine(self, engine='c'):
    1013 if engine == 'c':
    -> 1014self._engine = CParserWrapper(self.f, **self.options)
    1015 else:
    1016 if engine == 'python':

    ~/anaconda3/lib/python3.7/site-packages/pandas/io/parsers.py in __init__(self, src, **kwds)
    1706 kwds['usecols'] = self.usecols
    1707
    -> 1708self._reader = parsers.TextReader(src, **kwds)
    1709
    1710 passed_names = self.names is None

    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/raw/test.csv' does not exist

    Could you please help me what i have to set in order to read the file correctly.

    Thanks and Regards
    Mayank
    91- 8699587709
     
    #1

Share This Page