Phil-ZXX
Phil-ZXX

Reputation: 3265

Export Data from Externally-Hosted Jupyter Notebook

Currently, I am working on a few Jupyter notebooks, which aren't actually running on my local machine (Windows), but are hosted externally (Linux).

I don't have direct access to the Linux box, but can access its file system indirectly via Python. So there are no real restrictions as to what I can do (load files from the external machine, save files to the external machine, load packages, print data, etc). But the problem I am facing is, how do I export/extract any data from this "virtual" notebook onto my local machine? This is mainly for post-processing like plotting in Excel (or simply feeding the data into a different application).

For small/medium-sized arrays I can print(...) the data and then copy it. But is there a more elegant solution for larger data sets?

Upvotes: 0

Views: 623

Answers (1)

TrinTragula
TrinTragula

Reputation: 380

If you have the right permissions, you can start a webserver and download the files from there.

For Python 2.7

import SimpleHTTPServer
import SocketServer

PORT = 44444

Handler = SimpleHTTPServer.SimpleHTTPRequestHandler
httpd = SocketServer.TCPServer(("", PORT), Handler) 

print "Serving at port", PORT
httpd.serve_forever()

For Python 3:

import http.server
import socketserver

PORT = 44444

Handler = http.server.SimpleHTTPRequestHandler

httpd = socketserver.TCPServer(("", PORT), Handler)
print("serving at port", PORT)
httpd.serve_forever()

This will start a web server from the folder where you notebook is currently located. Then you can simply access it from your browser at www.example.com:44444

Upvotes: 2

Related Questions