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.
df.to_csv('filename.csv')
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
files.download('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:
- Click the folder icon (
📁
) in the left pane - If the CSV is not there, click
Refresh
- Right click the CSV
- Select
Download