'File not found error in Jupyter lab using python

I using online jupyterlab which can be accessed through this link below if not then use the second link

This is the second link

So the problem is i have uploaded a .csv format file to the lab but when i try to load it using this code

import pandas as pd
import matplotlib.pyplot as plt
from collections import Counter
import seaborn as sns

df = pd.read_csv ('demo/big.csv')

print(df)

It gives me the following error

FileNotFoundError                         Traceback (most recent call last)
<ipython-input-2-56c1e19c9da6> in <module>
  1 #Task 1
----> 2 df = pd.read_csv ('demo/big.csv')
  3 
  4 print(df)

/srv/conda/envs/notebook/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, skipfooter, 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, 
doublequote, escapechar, comment, encoding, dialect, tupleize_cols, error_bad_lines, 
warn_bad_lines, delim_whitespace, low_memory, memory_map, float_precision)
700                     skip_blank_lines=skip_blank_lines)
701 
--> 702         return _read(filepath_or_buffer, kwds)
703 
704     parser_f.__name__ = name

/srv/conda/envs/notebook/lib/python3.7/site-packages/pandas/io/parsers.py in 
_read(filepath_or_buffer, kwds)
427 
428     # Create the parser.
--> 429     parser = TextFileReader(filepath_or_buffer, **kwds)
430 
431     if chunksize or iterator:

/srv/conda/envs/notebook/lib/python3.7/site-packages/pandas/io/parsers.py in __init__(self, 
f, engine, **kwds)
893             self.options['has_index_names'] = kwds['has_index_names']
894 
--> 895         self._make_engine(self.engine)
896 
897     def close(self):

/srv/conda/envs/notebook/lib/python3.7/site-packages/pandas/io/parsers.py in 
_make_engine(self, engine)
1120     def _make_engine(self, engine='c'):
1121         if engine == 'c':
-> 1122             self._engine = CParserWrapper(self.f, **self.options)
1123         else:
1124             if engine == 'python':

/srv/conda/envs/notebook/lib/python3.7/site-packages/pandas/io/parsers.py in __init__(self, 
src, **kwds)
1851         kwds['usecols'] = self.usecols
1852 
-> 1853         self._reader = parsers.TextReader(src, **kwds)
1854         self.unnamed_cols = self._reader.unnamed_cols
1855 

pandas/_libs/parsers.pyx in pandas._libs.parsers.TextReader.__cinit__()

pandas/_libs/parsers.pyx in pandas._libs.parsers.TextReader._setup_parser_source()

FileNotFoundError: [Errno 2] File b'demo/big.csv' does not exist: b'demo/big.csv'

Please help me out did i gave the path incorrect or what is the problem here?



Solution 1:[1]

You should check and make sure that your notebook is in the same directory as the file you are trying to import. So if the notebook is in a folder on your desktop named "Notebooks" then place your data in that folder. Then, make sure that the

df = pd.read_csv ('demo/big.csv')

portion of your code only has the file name and .csv at the end. If the file is named big.csv then make it should be

df = pd.read_csv ('big.csv') 

Those are the main reasons you would be getting that error.

Solution 2:[2]

I'd recommend you to try using JupyterNotebook instead of JupyterLab to workaround this file directory problem

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1
Solution 2 ???