1

pwd ls import pandas as pd DF = pd.read_csv('~/downloads/world_mortality.csv')

FileNotFoundError                         Traceback (most recent call last)
Input In [10], in <cell line: 1>()
----> 1 DF = pd.read_csv('~/downloads/world_mortality.csv')

File ~\anaconda3\lib\site-packages\pandas\util\_decorators.py:311, in deprecate_nonkeyword_arguments.<locals>.decorate.<locals>.wrapper(*args, **kwargs)
    305 if len(args) > num_allow_args:
    306     warnings.warn(
    307         msg.format(arguments=arguments),
    308         FutureWarning,
    309         stacklevel=stacklevel,
    310     )
--> 311 return func(*args, **kwargs)

File ~\anaconda3\lib\site-packages\pandas\io\parsers\readers.py:678, in read_csv(filepath_or_buffer, sep, delimiter, header, names, index_col, usecols, squeeze, prefix, mangle_dupe_cols, dtype, engine, converters, true_values, false_values, skipinitialspace, skiprows, skipfooter, nrows, na_values, keep_default_na, na_filter, verbose, skip_blank_lines, parse_dates, infer_datetime_format, keep_date_col, date_parser, dayfirst, cache_dates, iterator, chunksize, compression, thousands, decimal, lineterminator, quotechar, quoting, doublequote, escapechar, comment, encoding, encoding_errors, dialect, error_bad_lines, warn_bad_lines, on_bad_lines, delim_whitespace, low_memory, memory_map, float_precision, storage_options)
    663 kwds_defaults = _refine_defaults_read(
    664     dialect,
    665     delimiter,
   (...)
    674     defaults={"delimiter": ","},
    675 )
    676 kwds.update(kwds_defaults)
--> 678 return _read(filepath_or_buffer, kwds)

File ~\anaconda3\lib\site-packages\pandas\io\parsers\readers.py:575, in _read(filepath_or_buffer, kwds)
    572 _validate_names(kwds.get("names", None))
    574 # Create the parser.
--> 575 parser = TextFileReader(filepath_or_buffer, **kwds)
    577 if chunksize or iterator:
    578     return parser

File ~\anaconda3\lib\site-packages\pandas\io\parsers\readers.py:932, in TextFileReader.__init__(self, f, engine, **kwds)
    929     self.options["has_index_names"] = kwds["has_index_names"]
    931 self.handles: IOHandles | None = None
--> 932 self._engine = self._make_engine(f, self.engine)

File ~\anaconda3\lib\site-packages\pandas\io\parsers\readers.py:1216, in TextFileReader._make_engine(self, f, engine)
   1212     mode = "rb"
   1213 # error: No overload variant of "get_handle" matches argument types
   1214 # "Union[str, PathLike[str], ReadCsvBuffer[bytes], ReadCsvBuffer[str]]"
   1215 # , "str", "bool", "Any", "Any", "Any", "Any", "Any"
-> 1216 self.handles = get_handle(  # type: ignore[call-overload]
   1217     f,
   1218     mode,
   1219     encoding=self.options.get("encoding", None),
   1220     compression=self.options.get("compression", None),
   1221     memory_map=self.options.get("memory_map", False),
   1222     is_text=is_text,
   1223     errors=self.options.get("encoding_errors", "strict"),
   1224     storage_options=self.options.get("storage_options", None),
   1225 )
   1226 assert self.handles is not None
   1227 f = self.handles.handle

File ~\anaconda3\lib\site-packages\pandas\io\common.py:786, in get_handle(path_or_buf, mode, encoding, compression, memory_map, is_text, errors, storage_options)
    781 elif isinstance(handle, str):
    782     # Check whether the filename is to be opened in binary mode.
    783     # Binary mode does not support 'encoding' and 'newline'.
    784     if ioargs.encoding and "b" not in ioargs.mode:
    785         # Encoding
--> 786         handle = open(
    787             handle,
    788             ioargs.mode,
    789             encoding=ioargs.encoding,
    790             errors=errors,
    791             newline="",
    792         )
    793     else:
    794         # Binary mode
    795         handle = open(handle, ioargs.mode)

FileNotFoundError: [Errno 2] No such file or directory: 'C:\\Users\\user/downloads/world_mortality.csv'

The final result says that I can't find the csv file in my downloads file. Can anyone help me to find problems with it. I've been trying for so long,but nothing helps at all.....The final result says that I can't find the csv file in my downloads file. Can anyone help me to find problems with it. I've been trying for so long,but nothing helps at all.....The final result says that I can't find the csv file in my downloads file. Can anyone help me to find problems with it. I've been trying for so long,but nothing helps at all.....The final result says that I can't find the csv file in my downloads file. Can anyone help me to find problems with it. I've been trying for so long,but nothing helps at all.....The final result says that I can't find the csv file in my downloads file. Can anyone help me to find problems with it. I've been trying for so long,but nothing helps at all.....The final result says that I can't find the csv file in my downloads file. Can anyone help me to find problems with it. I've been trying for so long,but nothing helps at all.....The final result says that I can't find the csv file in my downloads file. Can anyone help me to find problems with it. I've been trying for so long,but nothing helps at all.....The final result says that I can't find the csv file in my downloads file. Can anyone help me to find problems with it. I've been trying for so long,but nothing helps at all.....The final result says that I can't find the csv file in my downloads file. Can anyone help me to find problems with it. I've been trying for so long,but nothing helps at all.....The final result says that I can't find the csv file in my downloads file. Can anyone help me to find problems with it. I've been trying for so long,but nothing helps at all.....

Denny
  • 11
  • 1
  • Please follow the guide on [ask] a question on Stackoverflow and edit your post. It will be easier readble for other users and you will receive help faster. – FilipA Nov 22 '22 at 13:33
  • The path shown in the error has both forward and backward slashes in it, which suggests you're passing the wrong path for the CSV. I'd start by resolving that issue first. – FAB Nov 22 '22 at 13:37
  • 1
    As @FAB is trying to get you to realize, you are mixing and matching Unix-style path conventions with Windows use. For example, see about `~` for Home directory [here](https://fossbytes.com/home-directory-root-directory-symbols-forward-slash-tilde/) and the figure at the bottom of [here](https://www.pcmag.com/encyclopedia/term/backslash) about the slashes directions. You cannot just directly transpose file path conventions because what you are basing your code on is using Unix-style. For more help with Window paths, see ... – Wayne Nov 22 '22 at 18:59
  • [the links in my comment from yesterday](https://stackoverflow.com/questions/74517116/run-jupyter-notebook-from-another-jupyter-notebook#comment131555272_74517116). The pages linked are a good starting point because the notebook was Python based, even if the specific reason for encountering path issues isn't the same. – Wayne Nov 22 '22 at 19:01

1 Answers1

0

Did you check that the file exists in python? You can check that with os.path using the exist function os.path.exists(path).

steflbert
  • 116
  • 5