How to Download CSV From a Google Colab Python Notebook

How can we download a CSV created in in Google Colab to our local machine?

I recently exported a DataFrame to CSV and needed a way to download that CSV to my computer.

Suppose we run this line in the notebook.


How can we download this newly created CSV file?

Using files from google.colab

We can use built-in download functionality from google.colab to get the CSV to our local machine.

from google.colab import files'filename.csv')

Using the GUI

We can also just use the Google Colab GUI to achieve this.

As of January 2020, we can follow these steps:

  1. Click the folder icon (📁) in the left pane
  2. If the CSV is not there, click Refresh
  3. Right click the CSV
  4. Select Download