To mount the Google drive on to Collab,
from google.colab import drivedrive.mount('/content/drive')
Now after this the file can be accessed like this below
In this case below, The MyDrive is the folder
from os.path import exists
project_folder='/content/drive/MyDrive/TestFiles/Project_data.zip'
import zipfile
file_exists = exists(project_folder)
print("File Exists ", file_exists)
with zipfile.ZipFile(project_folder, 'r') as zip_ref:
zip_ref.extractall('Project_data')
In this case,
MyDrive was the root folder name that was displayed on the Google Collab file browser after mounting.
TestFiles folder contains the zip file which is tried to unzip. Unzipped files contain by default at the root folder in the default file system in Collab ( not drive)
No comments:
Post a Comment