How to download folders from Google Colaboratory
Download the folder directly from the files tab that you can find on an arrow on top left of the screen
https://colab.research.google.com/notebooks/io.ipynb
Is there a way to download data from a public link to google colab?
You can use gdown
.
For example, an image url
https://drive.google.com/file/d/1ztBz3C_2BlXgNGK2mbarGnVqoI287_XT/view?usp=sharing
It's id = 1ztBz3C_2BlXgNGK2mbarGnVqoI287_XT
So, you can download it with
!gdown --id 1ztBz3C_2BlXgNGK2mbarGnVqoI287_XT
How to download file created in Colaboratory workspace?
Use files colab lib
from google.colab import files
files.download('example.txt')
PS: use chrome browser
How to copy folders with same names recursively to another folder in Google Colab
The solution was to copy the files one by one recursively:
import os, shutil
for i in [x for x in range(10) if ((x != 9) and (x != 1))]:
# print(fileList[i])
# Train
if(i > 2):
subPathList = glob.glob('/content/NewDataset/'+fileList[i]+'/**/', recursive=False)
for subPath in subPathList:
for im in os.listdir(subPath):
imFullPath = os.path.join(subPath, im)
targetPath = os.path.join('/content/train',subPath.split('/')[-2]+ '/')
# print('Train: ', targetPath)
shutil.copy(imFullPath, targetPath)
# Validate
else:
subPathList = glob.glob('/content/NewDataset/'+fileList[i]+'/**/', recursive=False)
for subPath in subPathList:
for im in os.listdir(subPath):
imFullPath = os.path.join(subPath, im)
targetPath = os.path.join('/content/valid',subPath.split('/')[-2] + '/')
# print('Validate: ', targetPath)
shutil.copy(imFullPath, targetPath)
Related Topics
A Better Way Than Looping and Calling Functions That Loop and Call Another Functions
Pickle - Cpickle.Unpicklingerror: Invalid Load Key, '?'
Putting Multiple Conditions Using Np.Where on Python Pandas
How to Find the Maximum Consecutive Occurrences of a Number in Python
Numpy Distance Calculations of Different Shaped Arrays
Replace Single Quote to Double Quote Python Pandas Dataframe
How to Select Percentage of Rows in Pandas Dataframe
Pythonic Way to Find Maximum Value and Its Index in a List
How to Read Gz Compressed File by Pyspark
Pandas: Merging Two Columns into One With Corresponding Values
Splitting Dataframe into Multiple Dataframes
_Tkinter.Tclerror: No Display Name and No $Display Environment Variable
Write a Program That Find the Largest Integer in a String
Open() Gives Filenotfounderror/Ioerror: Errno 2 No Such File or Directory
Output the Same Amount of Rows as Asterisks Using For-Loop
How to Remove Commas and Dots of Individual Word in Two Dimensional List
Numpy Import Throws Attributeerror: 'Module' Object Has No Attribute 'Core'
Making Python Dictionary from a Text File With Multiple Keys