Accessing local folder using online Jupyter

Hi Experts,
I cannot install Anaconda or any other python application on my system. I am using jupyter online.

I need your help.
How to find the current working directory.

  1. How to change the Jupyter notebook current working directory to import os
# Function to Get the current `Preformatted text`
# working directory
def current_path():
    print("Current working directory before")
    print(os.getcwd())
    print()
    
# Driver's code
# Printing CWD before
current_path()
# Changing the CWD
os.chdir('../../')
# Printing CWD after
current_path()
**> OUTPUT : Current working directory before**
**> /**
os.chdir('C:/Data/CCSRP')
current_path()

**> OUTPUT: **
> ---------------------------------------------------------------------------
> FileNotFoundError Traceback (most recent call last)
> in
> 18 current_path()
**> 19 **
> —> 20 os.chdir(‘C:’)
> 21 current_path()
**> 22 **
**> **
> FileNotFoundError: [Errno 2] No such file or directory: 'C:
The command to change directory is throwing me error.
I am not even able to change the directory to “C:”

Please can you help ?

Regards

Hi

The working directory and directory paths relate to the environment that the notebook server is running on, not the desktop of the browser environment you are using to view a hosted notebook with.

If the Jupyter server you are accessing notebooks from is running on a server in a server farm in Amsterdam, or London or San Francisco, then the file paths relate to a virtual machine running on a server in a server rack in one of those locations.

You can upload files to a Jupyter notebook directory (from the classic notebook homepage, for example), or pull in files using tools like nbgitpuller. You can export files to your desktop using tools like nbzip. And you can also work with files saved to local browser storage using jupyter-offlinenotebook.

Another thing to note is that a notebook server is started in a particular directory on a particular filesystem and you cannot navigate to notebooks above that directory in the classic notebook homepage file view, although you can navigate to arbitrary directories on the command line / using shell commands.

3 Likes

@ [psychemedia] Thank you very much.
(Profile - psychemedia - Jupyter Community Forum)
Unfortunately, my place of work doesn’t allow me to install, upload data.

Please can you help me with links or help to read access
data from weblink, I have data from view source of the application, I am trying to extract data using regular expressions.

I need this logic

  1. From Jupiter, ability to read the websource link
  2. Using regular expressions and output to text file

One of the more straightforward ways of reading a URL in Python is via the requests package. But that is more of a Python question than a Jupyter question.

If you then need to parse files, or scrape data, then search for packages to do with screenscraping (things like beautifulsoup or scrapy.

But based on your previous comment, if you are viewing a local file in a browser (eg as file:///Users/YOURUSER/Path/datafile.csv) then running a Python environment launched via MyBinder on a server a thousand miles away won’t be able to see that location. You can only load remote data files if they are resolvable using something like http or ftp.

Can’t you just upload the file?