How to Import CSS File into Google Colab Notebook (Python3)

Is it possible to add .css style to Jupyter notebook from separate file?

If you are okay with the styling applying to all notebooks you make, then you can store your css in ~/.jupyter/custom/custom.css and this will be automatically loaded and will override any default styles.

An alternative is to do something like this:

from IPython.core.display import HTML
import urllib2
HTML(urllib2.urlopen('[url to your css file here').read())

(from http://moderndata.plot.ly/custom-styling-for-ipython-notebooks-with-3-lines-of-code/)

Where you store your css file somewhere (e.g. on Github) and download it and apply it when you run the notebook.

If you want it to be completely external, use custom.css, but this will apply to every notebook. If you need it to only apply to a single notebook, then you'll have to specify it within the notebook, but there are less verbose ways of doing it (like above).

See configuration docs

Convert Google Colab notebook to PDF / HTML?

You can save / export an IPython notebook (menu: File / Download .ipynb) and then use Jupyter to save to PDF.

Import `.csv` files from Google drive into Jupyter notebook

Given that your files are already hosted in the cloud and you are planning a collaborative scenario I think the idea proposed by @Eric is actually smarter.

Approach 1:

Otherwise, if you can't rely on that data source, you will have to build an authorization flow for your script to access Google Drive resources. You can see here a complete documentation on how to build your Python script and interact with the Google Drive API.

Approach 2:

Although, the Google Drive API requires authorization to access files URLs, you can build a workaround. Google Drive will generate some export links that, if your file is publicly available, will be accessible without authorization. In this Stack Overflow answer you can find more details about it.

In your Python script you will be able to parse the URL request directly without accessing the file system nor google drive authorization flow.



Related Topics



Leave a reply



Submit