1

I'm absolute new to python 3. I have the problem that I have a .csv file that is in a different folder than the .ipynb in which I code.

Jupyter Notebook Python 3 location: C:\Tools\Jupyter\test.ipynb

Data storage location C:\Users\my.name\OneDrive\python\data\cars.csv

If I place the .csv file directly to the Jupyter location, then opening it with pandas works.

import pandas as pd

df = pd.read_csv("./cars.csv")

Now I tried the following code to use the other location as file path, but it didn't work: "FileNotFoundError:".

import pandas as pd
df = pd.read_csv("C:/Users/my.name/OneDrive/python/data/cars.csv")

How can I open the file?

Sorry for that absolute beginners stuff..

I apriciate your help!

Skruff
  • 75
  • 1
  • 8
  • Try changing each / to \. Did it work? – Ricardo Rendich Aug 24 '20 at 09:37
  • 1
    looks like you've gotten the wrong path and that you're using windows. you need to prefix any path objects with an `r` i.e `r"C:\..."` if you are indeed using windows, a simple method would be to hold `shift` and `right-click` your file and click copy path, use that as your path for now but I would take some time and learn how to navigate your chosen operating system using the command line. – Umar.H Aug 24 '20 at 09:37
  • 1
    @Manakin Thanks a lot! Presenting the r "C:\" has provided the solution! Great Community – Skruff Aug 24 '20 at 09:47

0 Answers0