Filepaths in Jupyter

Hi there,

I am not sure how I can change Jupyter to read a home directory for reading the “AppleStore.csv” file other than giving an absolute path. Is there a way to set a PATH to search?. Currently, I have it in the same location as my program file.

I do not see any output after it reads the file successfully.

Thanks,
Kalyan

Hey, Kalyan.

To read from the current directory it’s enough to use the filename, just like you did.

You don’t see any output because the open function doesn’t output anything when it reads a file successfully, that’s the expected behavior.

Yes, you can change your current working directory by using os.chdir. Here’s an example.

>>> import os
>>> os.getcwd()
'/media/HDD Disk/Scratch'

This shows us that the current working directory is /media/HDD Disk/Scratch. Let’s change it to /home/bruno.

>>> os.chdir("/home/bruno")
>>> os.getcwd()
'/home/bruno'

From this moment on, to refer to the files in /home/bruno, I just need to use their filename.

I hope this helps.