1 min read

How to Download Files from Colab

Making it easy to download a file from 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, it does come with some differences, such as downloading files from Colab. Follow the guide below to learn exactly how to download files from Google Colab.

The below 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. If you have all this set up, read on for our guide on importing and downloading files on Colab.




How to download a file created in Google Colab workspace?

To download a file for Colab lib use, 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 Google Colab workspace?

Another function we can use is saving a Google Colab 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:


Paid Media Agency

Enjoy this blog? 

Honcho are a UK Search Marketing Agency specialising in SEO, Paid Search and Digital PR

Get in touch to find out how we can help you scale your brand online. 

New call-to-action

Explore Our Services

DIGITAL PR 

Earn authoritative links and drive brand awareness with Digital PR

PAID SEARCH

Deliver instant traffic and revenue through Paid Search and Shopping

SOCIAL ADS

Reach new audiences and retarget existing ones on social channels 

CONTENT

Attract and engage website visitors with a well executed content strategy

What is Google Search Generative Experience? (SGE)

2 min read

What is Google Search Generative Experience? (SGE)

What is Google SGE? Think of Google SGE as your helpful buddy on the search results page. Instead of making you click on different websites, it pulls...

Read More
Harnessing High Search Volume Keywords for Maximum Impact

5 min read

Harnessing High Search Volume Keywords for Maximum Impact

Discover the power of high search volume keywords and how to effectively use them to boost your online presence and drive maximum impact.

Read More
Honcho partner with Eflorist to support Digital PR campaigns across Europe

2 min read

Honcho partner with Eflorist to support Digital PR campaigns across Europe

We're delighted to officially announce our partnership with Eflorist, one of the world’s leading flower delivery brands with over 54,000 local flower...

Read More

Google My Business Update June 2019

Google My Business Update: 6 New Features According to Google, Google My Business (GMB) has allowed 150 million local businesses connect with local...

Read More

1 min read

Google Caffeine Update

Back in August iThinkMedia discussed the preview of Google’s new algorithm update nicknamed Google Caffeine. Since that release Google have received...

Read More

Gary Illyes from Google responds to SEO conspiracy theories

Last week, Google’s webmaster analyst Gary Illyes held an AMA session on Reddit. Users asked him various questions around SEO ranking theories which...

Read More