4

I want to import a csv file from google drive . I tried using the link in add dataset tab but it is taking some thing else as "Open". Please see the image.

enter image description here

Monukumar
  • 41
  • 1
  • 1
  • 2

4 Answers4

6
  1. Go to your Google Drive and right click the dataset you want to upload to Kaggle.

  2. Generate the shareable link and the code that comes after https://drive.google.com/open?id=, it should be a long code (like 3tlxSE__5eL3q7Zb31M3CEKHlieGWZYgM)

  3. Insert the long code at the end of https://drive.google.com/uc?export=download&id=

  4. Copy that link. Should look something like https://drive.google.com/uc?export=download&id=3tlxSE__5eL3q7Zb31M3CEKHlieGWZYgM

  5. When uploading a dataset to Kaggle, select to add a file from remote URL.

  6. Insert copied URL.

  7. Done!

5

Use gdown to directly download your google drive file into your session every time. The download speed is pretty high so it wont take much time.

!gdown https://drive.google.com/uc?id=YOUR_FILE_ID

The file id can obtained by the method described in the previous answer.

3

Here's the solution that works every time and very efficiently.

A) Case of file

import torchvision  
torchvision.datasets.utils.download_file_from_google_drive(file_id, root, filename=None, md5=None)

This download a Google Drive file and place it in root.
Args:
- file_id (str): id of file to be downloaded
- root (str): Directory to place downloaded file in
- filename (str, optional): Name to save the file under. If None, use the id of the file.
- md5 (str, optional): MD5 checksum of the download. If None, do not check

B) Case of folder

1.launch google colab and log into your google drive account.
2. zip the folder :
%cd /content/drive/"My drive"/.../my_folder
! zip -r archive_name.zip my_folder

So you can download this zip file with torchvision wherever you want (filename=archive_name.zip), and unzip it with :
! unzip archive_name.zip -d my_folder

2

This works for me, pip install gdown won't work in Kaggle so follow this:

!conda install -y gdown
!gdown https://drive.google.com/uc?id=ID_HERE

======================= or ==================

!conda install -y gdown 
import gdown 
url = 'https://drive.google.com/uc?id=ID_HERE' 
output = 'myfile.zip'
gdown.download(url, output)

Your google drive id can be found from shared link

NelsonGon
  • 107
  • 4
Biplob Das
  • 121
  • 2