Search code examples
pythonpandascsvimport

FileNotFoundError while importing a csv file using pandas in Jupyter notebook


Screenshot of the described error.

import pandas as pd
df = pd.read_csv('/home/josepm/Documents/test_ver2.csv')

---------------------------------------------------------------------------
FileNotFoundError                         Traceback (most recent call last)
<ipython-input-3-5cd7fd573fb7> in <module>()
      1 import pandas as pd
----> 2 df = pd.read_csv('/home/josepm/Documents/test_ver2.csv')

I try to import a CSV file using pandas and every time it says that it doesn't find the file. It's like Jupyter doesn't see it. I tried to do this:

import os
os.path.isfile('/home/josepm/Documents/test_ver2.csv')

and it doesn't see the file either.


Solution

  • Change

    pd.read_csv('\Users\user\Desktop\Workbook1.csv')
    

    to

    pd.read_csv(r'C:\Users\user\Desktop\Workbook1.csv')