Google Colab Download file

0

3 Ways to download file on Google Colab

1. Url File

Install library

#install Libary!pip install wget
!pip install gdown

import library

import wget
import gdown

Download by wget

file_from = 'https://storage.googleapis.com/piyaphanwebsite.appspot.com/Colab/download.zip'
file_to = '/content/download4.zip'
wget.download(file_from,file_to) 

Download by gdown

file_from = 'https://storage.googleapis.com/piyaphanwebsite.appspot.com/Colab/download.zip'
file_to = '/content/download3.zip'
gdown.download(file_from,file_to)

2. Google Drive shared file

Install library

#install Libary
!pip install gdown

import library

import gdown

Download by gdown

#google shaired file https://drive.google.com/file/d/1YMiJtNFE4t45_gnW7B_u_Y5sd89AiRCi/view?usp=sharing

ID : 1YMiJtNFE4t45_gnW7B_u_Y5sd89AiRCi

!gdown –id 1YMiJtNFE4t45_gnW7B_u_Y5sd89AiRCi

#google shaired file https://drive.google.com/file/d/1YMiJtNFE4t45_gnW7B_u_Y5sd89AiRCi/view?usp=sharing
#gdown id is 1YMiJtNFE4t45_gnW7B_u_Y5sd89AiRCi
!gdown --id 1YMiJtNFE4t45_gnW7B_u_Y5sd89AiRCi

/usr/local/lib/python3.7/dist-packages/gdown/cli.py:131: FutureWarning: Option `–id` was deprecated in version 4.3.1 and will be removed in 5.0. You don’t need to pass it anymore to use a file ID. category=FutureWarning, Downloading… From: https://drive.google.com/uc?id=1YMiJtNFE4t45_gnW7B_u_Y5sd89AiRCi To: /content/download.zip 100% 727k/727k [00:00<00:00, 109MB/s]


3. Copy from mount drive(Google Drive)

Mount Google Drive

from google.colab import drive
drive.mount('/content/drive')

Drive already mounted at /content/drive; to attempt to forcibly remount, call drive.mount(“/content/drive”, force_remount=True).

Try copy frim file location by linux command

!cp is copy command

/content/drive/MyDrive/SuperAI/SuperAI-Pangpuriye/File/download.zip is source file

-d /content/New_Folder/download1.zip is copy to location and file name

!cp /content/drive/MyDrive/SuperAI/SuperAI-Pangpuriye/File/download.zip -d /content/download1.zip

Special Technic

You can apply wget or gdown with mount google drive to donwload file dataset to Google drive

your file will place on google drive without uploading to google drive

file_from = 'https://storage.googleapis.com/piyaphanwebsite.appspot.com/Colab/download.zip'
file_to = '/content/drive/MyDrive/SuperAI/SuperAI-Pangpuriye/File/download.zip'
wget.download(file_from,file_to)