Exporting Data from google colab to local machine

Solution 1:

Try this

from google.colab import files
files.download("data.csv")

Update(Sep 2018): now it's even easier

  • open the left pane
  • select 'Files' tab
  • click 'Refresh'
  • right click the file, then download

Update (Jan 2020): the UI changes

  • click on the folder icon on the left pane (3rd icon)
  • click 'Refresh'
  • right click the file, then download

Solution 2:

Try this:

First you can save the file using pandas to_csv functionality later on you can download that file using google colab files functionality.

from google.colab import files
df.to_csv('filename.csv') 
files.download('filename.csv')

Solution 3:

Downloading files to your local file system

files.download will invoke a browser download of the file to your local computer.

from google.colab import files

with open('example.txt', 'w') as f:
  f.write('some content')

files.download('example.txt')