Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 531
Josep M Domingo Avatar asked Sep 19 '25 23:09

Josep M Domingo


2 Answers

Change

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

to

pd.read_csv(r'C:\Users\user\Desktop\Workbook1.csv')
like image 186
Chankey Pathak Avatar answered Sep 22 '25 13:09

Chankey Pathak


Please try the following code:

import os  
path = os.path.abspath(r'file path')
f = open(path)
print(f)
like image 32
S. HU Avatar answered Sep 22 '25 12:09

S. HU