How to upload and save big data in Google Colaboratory from a local drive?

I downloaded big image training data as a zip from this Kaggle link

https://www.kaggle.com/c/yelp-restaurant-photo-classification/data

How to effectively achieve the following?

  • Create a project folder in Google Colaboratory
  • Upload zip file to project folder
  • unzip files

thank

EDIT: I tried the code below, but its crashing for my large zip file. Is there a better / efficient way to do this when I can just specify the location of the file on the local drive?

from google.colab import files
uploaded = files.upload()

for fn in uploaded.keys():
  print('User uploaded file "{name}" with length {length} bytes'.format(
      name=fn, length=len(uploaded[fn])))
+4
source share
5 answers
!pip install kaggle
api_token = {"username":"USERNAME","key":"API_KEY"}
import json
import zipfile
import os
with open('/content/.kaggle/kaggle.json', 'w') as file:
    json.dump(api_token, file)
!chmod 600 /content/.kaggle/kaggle.json
!kaggle config set -n path -v /content
!kaggle competitions download -c jigsaw-toxic-comment-classification-challenge
os.chdir('/content/competitions/jigsaw-toxic-comment-classification-challenge')
for file in os.listdir():
    zip_ref = zipfile.ZipFile(file, 'r')
    zip_ref.extractall()
    zip_ref.close()

9 , . : https://gist.github.com/jayspeidell/d10b84b8d3da52df723beacc5b15cb27 rep.

+2

:

-. , xls Google . gspread -.

+1

kaggle-cli, .

fast.ai.

+1

script, Kaggle API Colab. , API .

https://gist.github.com/jayspeidell/d10b84b8d3da52df723beacc5b15cb27

Colab , wget API, , . , .

0

- Dropbox ( ), .

!wget link -0 new-name && ls
0

Source: https://habr.com/ru/post/1693809/


All Articles