(+44) 01438 870220
(+44) 01438 870220

How to download files from Google Colab


Blog Article

What is Google Colab?

Google Colab or “Colaboratory” is a product from Google research. Colab allows users to write and execute Python Code useful for Data Analysis or Machine Learning. Google Colab is hosted on Jupyter Notebook so is easily accessible to users that are already familiar with Jupyter. A great advantage over Juptyer Notebook, Google Colab requires no set-up or install to use and provides free access to computing resource including GPU and RAM.

However, using Google Colab does come with some differences, such as downloading and accessing files from Colab.

The bellow assumes you have a data frame which has been named as a file and assigned a type. This will most commonly be done via Pandas, for example: result.to_csv(‘example_file.csv’)

It also assumes you have mounted your Google drive in the Colab interface.




How to download a file created in Colaboratory workspace?

To download a file you can use the Colab lib, however, you will need to use the Google Chrome Browser. If you are using Firefox, then this won’t work.

from google.colab import files
import pandas as pd
result.to_csv('example_file.csv')
files.download('example_file.csv')

Once executed, this will download the file directly to your downloads.

How to add a file into Google Drive from Colaboratory workspace?

Another function we can use is saving a file to Google Drive, this can then be used in another script or downloaded by others in a shared drive.

from google.colab import files
import pandas as pd
result.to_csv('example_file.csv')
!cp example_file.csv "/content/drive/My Drive/"

Once executed this will download the file to your specified Google Drive location.

Google Pytrends Script - Google Colab Download Example


We love Google Colab for its ease of use and the fact it doesn’t stress out our own hardware. For more useful tips and advice on Python, follow our blog and subscribe to our mailing list.

For more Python and how it can help your digital marketing, check out:


GET IN TOUCH

Find out more about how we can maximise your search marketing performance. Fill in the form below or call us on 01438 870220.

August Search Updates

August Search Updates

How to download files from Google Colab

How to download files from Google Colab

July Search Updates

July Search Updates

The best Chrome extensions, you’ve (maybe) never heard of for digital marketers

The best Chrome extensions, you’ve (maybe) never heard of for digital marketers