Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/woctezuma/google-colab-transfer
Transfer data between Colab and Drive. Available on PyPI.
https://github.com/woctezuma/google-colab-transfer
google-colab google-colaboratory google-drive
Last synced: 17 days ago
JSON representation
Transfer data between Colab and Drive. Available on PyPI.
- Host: GitHub
- URL: https://github.com/woctezuma/google-colab-transfer
- Owner: woctezuma
- License: mit
- Created: 2019-12-23T10:39:58.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2024-11-14T17:08:32.000Z (about 1 month ago)
- Last Synced: 2024-11-15T20:38:51.321Z (about 1 month ago)
- Topics: google-colab, google-colaboratory, google-drive
- Language: Python
- Homepage: https://pypi.org/project/Google-Colab-Transfer/
- Size: 28.3 KB
- Stars: 12
- Watchers: 4
- Forks: 2
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Colab Transfer: transfer data between Colab & Drive
[![PyPI status][pypi-image]][pypi]
[![Build status][build-image]][build]
[![Code coverage][codecov-image]][codecov]
[![Code Quality][codacy-image]][codacy]
This repository contains Python code to transfer data between [Google Colab](https://colab.research.google.com) and [Google Drive](https://www.google.com/drive/).> Disclaimer: If files or folders already exist at the destination, then they will not be overwritten. If you want to force an update, ensure that you delete them first.
## Installation
The code is packaged for [PyPI](https://pypi.org/project/Google-Colab-Transfer/), so that the installation consists in running:
```bash
pip install colab_transfer
```## Usage
### Get the path to the home folder of the local machine for your session on Colaboratory
```python
import colab_transfercolab_path = colab_transfer.get_path_to_home_of_local_machine()
```### Get the path to the home folder on Google Drive
```python
import colab_transferdrive_path = colab_transfer.get_path_to_home_of_google_drive()
```### Mount Google Drive
NB: you will have to manually input the authorization code.
```python
import colab_transfercolab_transfer.mount_google_drive()
```### Check whether Google Drive is mounted
```python
import colab_transfergoogle_drive_is_mounted = colab_transfer.is_google_drive_mounted()
```### Copy a file from Drive to Colaboratory
```python
import colab_transfercolab_path = colab_transfer.get_path_to_home_of_local_machine()
drive_path = colab_transfer.get_path_to_home_of_google_drive()input_file_name = 'dummy_file.txt'
colab_transfer.copy_file(
file_name=input_file_name,
source=drive_path,
destination=colab_path,
)
```### Copy a file from Colaboratory to Drive
```python
import colab_transfercolab_path = colab_transfer.get_path_to_home_of_local_machine()
drive_path = colab_transfer.get_path_to_home_of_google_drive()input_file_name = 'dummy_file.txt'
colab_transfer.copy_file(
file_name=input_file_name,
source=colab_path,
destination=drive_path,
)
```### Copy a folder structure from Drive to Colaboratory
```python
import colab_transfercolab_path = colab_transfer.get_path_to_home_of_local_machine()
drive_path = colab_transfer.get_path_to_home_of_google_drive()input_folder_name = 'dummy_folder/'
colab_transfer.copy_folder_structure(
source=drive_path + input_folder_name,
destination=colab_path + input_folder_name,
)
```Alternatively:
```python
import colab_transfercolab_path = colab_transfer.get_path_to_home_of_local_machine()
drive_path = colab_transfer.get_path_to_home_of_google_drive()input_folder_name = 'dummy_folder/'
colab_transfer.copy_folder(
folder_name=input_folder_name,
source=drive_path,
destination=colab_path,
)
```### Copy a folder structure from Colaboratory to Drive
```python
import colab_transfercolab_path = colab_transfer.get_path_to_home_of_local_machine()
drive_path = colab_transfer.get_path_to_home_of_google_drive()input_folder_name = 'dummy_folder/'
colab_transfer.copy_folder_structure(
source=colab_path + input_folder_name,
destination=drive_path + input_folder_name,
)
```Alternatively:
```python
import colab_transfercolab_path = colab_transfer.get_path_to_home_of_local_machine()
drive_path = colab_transfer.get_path_to_home_of_google_drive()input_folder_name = 'dummy_folder/'
colab_transfer.copy_folder(
folder_name=input_folder_name,
source=colab_path,
destination=drive_path,
)
```[pypi]: https://pypi.python.org/pypi/Google-Colab-Transfer
[pypi-image]: https://badge.fury.io/py/Google-Colab-Transfer.svg[build]:
[build-image]:
[publish-image]:[pyup]: https://pyup.io/repos/github/woctezuma/google-colab-transfer/
[dependency-image]: https://pyup.io/repos/github/woctezuma/google-colab-transfer/shield.svg
[python3-image]: https://pyup.io/repos/github/woctezuma/google-colab-transfer/python-3-shield.svg[codecov]: https://codecov.io/gh/woctezuma/google-colab-transfer
[codecov-image]: https://codecov.io/gh/woctezuma/google-colab-transfer/branch/master/graph/badge.svg[codacy]: https://www.codacy.com/app/woctezuma/google-colab-transfer
[codacy-image]: https://api.codacy.com/project/badge/Grade/8d61b0dec7c346289a73f4cc3a760c53