Juypter Notebook | CSV&XLXS | File not found

47 views Asked by At

When I try to open files using pd.read_cvs, or pd.read_excel in Juytper notebooks I keep getting file not found Error 2

I'm currently working through a python book called "Python for MBAS," and I am at the section where it teaches how to upload excel and cvs files from your local computer to juypter notebooks. When following the steps that the books has given me I continue to get the File not found error error 2.

I used the os os.cwd, os.chdir method, but nothing seems to be working. Also when I open the excel file it says that is not Unicoded - 8, but when I checked the document its says that it has the correct unicode.[enter image description here](https://i.stack.imgur.com/LECEr.png)

I have been at this for over a week at this point.

import pandas as pd import numpy as np import os

'
df_weather = pd.read_excel('raw data\Students.xlsx')
---------------------------------------------------------------------------
FileNotFoundError                         Traceback (most recent call last)
Cell In[14], line 1
----> 1 df_weather = pd.read_excel('raw data\Students.xlsx')

File ~/anaconda3/lib/python3.11/site-packages/pandas/io/excel/_base.py:504, in read_excel(io, sheet_name, header, names, index_col, usecols, dtype, engine, converters, true_values, false_values, skiprows, nrows, na_values, keep_default_na, na_filter, verbose, parse_dates, date_parser, date_format, thousands, decimal, comment, skipfooter, storage_options, dtype_backend, engine_kwargs)
    502 if not isinstance(io, ExcelFile):
    503     should_close = True
--> 504     io = ExcelFile(
    505         io,
    506         storage_options=storage_options,
    507         engine=engine,
    508         engine_kwargs=engine_kwargs,
    509     )
    510 elif engine and engine != io.engine:
    511     raise ValueError(
    512         "Engine should not be specified when passing "
    513         "an ExcelFile - ExcelFile already has the engine set"
    514     )

File ~/anaconda3/lib/python3.11/site-packages/pandas/io/excel/_base.py:1563, in ExcelFile.__init__(self, path_or_buffer, engine, storage_options, engine_kwargs)
   1561     ext = "xls"
   1562 else:
-> 1563     ext = inspect_excel_format(
   1564         content_or_path=path_or_buffer, storage_options=storage_options
   1565     )
   1566     if ext is None:
   1567         raise ValueError(
   1568             "Excel file format cannot be determined, you must specify "
   1569             "an engine manually."
   1570         )

File ~/anaconda3/lib/python3.11/site-packages/pandas/io/excel/_base.py:1419, in inspect_excel_format(content_or_path, storage_options)
   1416 if isinstance(content_or_path, bytes):
   1417     content_or_path = BytesIO(content_or_path)
-> 1419 with get_handle(
   1420     content_or_path, "rb", storage_options=storage_options, is_text=False
   1421 ) as handle:
   1422     stream = handle.handle
   1423     stream.seek(0)

File ~/anaconda3/lib/python3.11/site-packages/pandas/io/common.py:872, in get_handle(path_or_buf, mode, encoding, compression, memory_map, is_text, errors, storage_options)
    863         handle = open(
    864             handle,
    865             ioargs.mode,
   (...)
    868             newline="",
    869         )
    870     else:
    871         # Binary mode
--> 872         handle = open(handle, ioargs.mode)
    873     handles.append(handle)
    875 # Convert BytesIO or file objects passed with an encoding

FileNotFoundError: [Errno 2] No such file or directory: 'raw data\\Students.xlsx'
0

There are 0 answers