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.
4 Answers
Go to your Google Drive and right click the dataset you want to upload to Kaggle.
Generate the shareable link and the code that comes after
https://drive.google.com/open?id=, it should be a long code (like3tlxSE__5eL3q7Zb31M3CEKHlieGWZYgM)Insert the long code at the end of
https://drive.google.com/uc?export=download&id=Copy that link. Should look something like
https://drive.google.com/uc?export=download&id=3tlxSE__5eL3q7Zb31M3CEKHlieGWZYgMWhen uploading a dataset to Kaggle, select to add a file from remote URL.
Insert copied URL.
Done!
- 61
- 1
-
But still getting https://imgur.com/a/B6zcxaX – Monukumar Jun 01 '19 at 00:53
-
And there is no error code whatsoever from Kaggle? – Nicolas Essipova Jun 01 '19 at 08:54
-
Have you ever tried it yourself? It does not work at all! – Arman Malekzadeh Mar 01 '20 at 16:28
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.
- 51
- 1
- 1
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
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
- 107
- 4
- 121
- 2
