4

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.

6
  • Could you post the error message? Commented Oct 9, 2017 at 10:02
  • Well the error is self explanatory... you have to find out the right pathe to the file.. Commented Oct 9, 2017 at 10:03
  • I copied the path from the file properties option panel. It should be this one. How can I find the correct one? Screenshot of the file: link Commented Oct 9, 2017 at 10:07
  • are u connected to a remote notebook by any chance? Commented Oct 9, 2017 at 10:17
  • I'm using the browser version of Jupyter. Maybe that's the problem. Commented Oct 9, 2017 at 10:23

5 Answers 5

5

Change

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

to

pd.read_csv(r'C:\Users\user\Desktop\Workbook1.csv')
Sign up to request clarification or add additional context in comments.

1 Comment

I tried this and this worked for me as well.
1

Please try the following code:

import os  
path = os.path.abspath(r'file path')
f = open(path)
print(f)

Comments

1

The working directory is the point from where all the files are accessed in Jupyter Notebook.

Find the current working directory

import os

os.getcwd()

Example o/p : 'C:\Users\xyz'

Now place your CSV files in this path

List the contents of your directory to check if the CSV file is present

os.listdir('C:\Users\xyz')

Now try reading the CSV file

Comments

1

Copy the file directory, then paste it here:

pd.read_csv(r'(here)\(csv file name including .csv)').

for example:

pd.read_csv(r'C:\Users\DCL\ML and related\Bengaluru_House_Data.csv')

Hope this will work.

Comments

0

Well, This is not a coding error if you are using Jupiter Notebook.

Just look at your csv file size. if it is nothing showing the file size

you need to upload your csv data one more time like thisClick here to see image

in my case see the image and it shows the file size

1 Comment

As it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.