Let me ask a question about the title.

Using Google Colab, this article I want to download the data.

#kaggleAPI upload
from google.colab import files
files.upload ()
! mkdir -p ~/.kaggle
! mv kaggle.json ~/.kaggle /

from google.colab import drive
drive.mount ('/ root/drive')
! chmod 600 /root/.kaggle/kaggle.json
! kaggle competitions download -c dogs-vs-cats

When the above code was executed, the following message appeared.

Warning: Looks like you're using an outdated API Version, please consider updating (server 1.5.6/client 1.5.4)

When I examined it, there is an article that the 403 error occurs because it is not joined to the Kaggle competition,
This competition is already over and there is no button to join.

How can I download a dataset from Google Colab?

If i know anyone, I would appreciate it.

  • Answer # 1

    from google.colab import drive
    drive.mount ('/ root/drive')
    import os
    ! mkdir -p Colab
    os.getcwd ()
    '/ content/Colab'

    If you look at Google Drive in this state, you can see the Colab directory, so if you copy the file from the PC side, it will be uploaded.

    ! ls -lsa/root/drive/My \ Drive/Colab /
    total 304
    304 -rw ------- 1 root root 310547 Aug 24 07:03 39766.pdf

  • Answer # 2

    You may not understand the intent of the question, but Isn't it downloaded by pressing the "Download All" button on the page?

    Dogs vs. Cats

    I think you upload the code when you run it. . .

    ! pip install -U kaggle

    The message has changed.

    Saving kaggle.json to kaggle.json
    Drive already mounted at/root/drive;to attempt to forcibly remount, call drive.mount ("/ root/drive", force_remount = True).

  • Answer # 3


    The 403 error occurs because you are not joining the Kaggle competition

    As you said, you can download it when you join another competition.

    ! kaggle competitions download -c severstal-steel-defect-detection
    Downloading severstal-steel-defect-detection.zip to/content/Colab
    100% 1.29G/1.29G [00:12<00:00, 102MB/s]
    100% 1.29G/1.29G [00:12<00:00, 115MB/s]

    Since the desired competition is over, can I just drop it locally from the "Download All" button and upload it?

    The operation of kaggle was based on the following Qiita article.
    [Python memo] Unusual code&usage using the Kaggle API in Google Colaboratory