FileNotFoundError trying to read data file from Jupyter in Pycharm

I am new to Jupyter and I am trying to read the .csv file with no luck.

I have these files:
data/mydatafile.csv


scripts/myscript.py


scripts/mynotebook.ipynb

Q myscript.py

I can read the data file successfully by accessing the ../data/mydatafile.csv

. But trying to do the same in mynotebook.ipynb

results in FileNotFoundError: File b'../data/mydatafile.csv' does not exist

.

What can I do to make this work? I am writing my code in Pycharm if it matters.

Version Information: enter image description here

+3


source to share


2 answers


@fiveclubs gives the right look. In fact, in your Jupiter script, you should check your "Working Directory". There are two ways to get it.

  • In your Jupiter's head script, import os print(os.getcwd())

    then add the required prefix name of your directory. I have the same problem because the folder name is missing.
  • In a script window Configurations

    to checkWorking directory



Overall, I think the first method is better.

Hope this would be helpful.

0


source


In your startup configuration, make sure the "Working Directory" field matches where you are specifying your relative path.



-1


source







All Articles