Skip to content

Commit

Permalink
Add back Google Sheets support and remove outdated code (#23)
Browse files Browse the repository at this point in the history
* refactor: remove outdated functions

* feat: add back google sheets support

* pkg: remove unneeded dependencies

* fix: fix the drive export url

* test: update the tests to match new functions

* docs: add a docstring for sheet_download_url

* docs: update the documentation to the unified download function

* docs: remove outdated information in the readme

* docs: fix typos in the documentation

* pkg: bump version to 0.2.0

* refactor: export a google_download_url function

* fix: accept file paths and commands as download locations

* docs: remove outdated information from the readme

* test: expand test coverage

* pkg: add compat entry for Downloads
  • Loading branch information
flexagoon authored Dec 11, 2023
1 parent bea1196 commit 033063a
Show file tree
Hide file tree
Showing 6 changed files with 70 additions and 270 deletions.
10 changes: 2 additions & 8 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,17 +1,11 @@
name = "GoogleDrive"
uuid = "91feb7a0-3508-11ea-1e8e-afea2c1c9a19"
authors = ["tejasvaidhyadev <[email protected]> and contributors"]
version = "0.1.3"
version = "0.2.0"

[deps]
DataDeps = "124859b0-ceae-595e-8997-d05f6a7a8dfe"
Dates = "ade2ca70-3891-5945-98fb-dc099432e06a"
Downloads = "f43a241f-c20a-4ad4-852c-f6b1247861c6"
HTTP = "cd3eb016-35fb-5094-929b-558a96fad6f3"
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"

[compat]
DataDeps = "0.7.10"
Downloads = "1"
HTTP = "1.4.0"
julia = "1.9"
Downloads = "1"
73 changes: 1 addition & 72 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,7 @@ https://github.com/JuliaIO/GoogleDrive.jl

## Introduction

GoogleDrive.jl provides support for downloading files from Google Drive,
directly as an IO stream,
or on top of
[DataDeps.jl](https://github.com/oxinabox/DataDeps.jl).

GoogleDrive.jl provides support for downloading files from Google Drive and Google Sheets.

### Installation
Install the package using the
Expand All @@ -32,9 +28,6 @@ pkg> add GoogleDrive

## Details

Some of the methods in this package
may no longer be needed
because of changes to Google Drive API.

To download data into an IO stream from a special URL of the form
`url = "https://docs.google.com/uc?export=download&id=1GqmszfSB_LHGQEQpSjoiPyDROZ5a8Ls4"`,
Expand All @@ -59,77 +52,13 @@ google_download(url, io)
str = String(take!(io)) # (this line for text data only)
```


### drive_download
`drive_download(URL, localdir)`

Download file from Google drive.
The above function only Download file from google drive.


### sheet_handler
`sheet_handler(long_url)`

Provide URL that can be use as link for registering in Datadeps


### google_download
`google_download(URL, localdir)`

It can also be consider as "maybe google download function"
The function can be used to download a file from
google-drive, google-sheets or HTTP download method.


## Configuration
This package is build on top of
[DataDeps.jl](https://github.com/oxinabox/DataDeps.jl).
To configure, e.g., where downloaded files save to, and read from
(and to understand how that works),
see the DataDeps.jl readme.


## Examples

Load the package with

```
julia> using GoogleDrive
```

### Loading different Embeddings

Downloading CSV file from GoogleDrive using `google_download` function
```
julia> google_download("https://docs.google.com/spreadsheets/d/1tbNIGxnp8wLk31DIMNPD_Hi_CmIdpdTPfzMUDcs1xE/edit#gid=0", "/home/iamtejas/Downloads")
┌ Info: Downloading
│ source = "https://docs.google.com/spreadsheets/d/1tbNI-Gxnp8wLk31DIMNPD_Hi_CmIdpdTPfzMUDcs1xE/export?format=csv"
│ dest = "/home/iamtejas/Downloads/InternshipsToApplyFor-Sheet1.csv"
│ progress = NaN
│ time_taken = "0.05 s"
│ time_remaining = "NaN s"
│ average_speed = "84.961 KiB/s"
│ downloaded = "4.163 KiB"
│ remaining = "∞ B"
└ total = "∞ B"
"/home/iamtejas/Downloads/InternshipsToApplyFor-Sheet1.csv"
```

## Contributing and Reporting Bugs

Contributions, in the form of bug-reports, pull requests, additional documentation are encouraged. They can be made to the Github repository.

**All contributions and communications should abide by the
[Julia Community Standards](https://julialang.org/community/standards/).**


### Reference

Code:-
[Peter Cheng](https://github.com/chengchingwen/Transformers.jl), [HTTPS](https://github.com/JuliaWeb/HTTP.jl)


<!-- URLs -->
[action-img]: https://github.com/JuliaIO/GoogleDrive.jl/workflows/CI/badge.svg
[action-url]: https://github.com/JuliaIO/GoogleDrive.jl/actions
Expand Down
52 changes: 13 additions & 39 deletions docs/src/features.md
Original file line number Diff line number Diff line change
@@ -1,52 +1,26 @@
## functions

### drive_download
`drive_download(URL, localdir)`
### google_download

`google_download(URL, IO)`

Download a file from Google Drive or Google Sheets.

Download flie from Google drive.
The above function only Download file from google drive.
Downloading CSV file from google_drive using google_download function
#### Example
```
julia>drive_download("https://drive.google.com/file/d/0B9w48e1rj-MOLVdZRzFfTlNsem8/view")
┌ Info: Downloading
│ source = "https://drive.google.com/file/d/0B9w48e1rj-MOLVdZRzFfTlNsem8/view"
│ dest = "/home/iamtejas/Downloads/InternshipsToApplyFor-Sheet1.csv"
│ progress = NaN
│ time_taken = "0.05 s"
│ time_remaining = "NaN s"
│ average_speed = "84.961 KiB/s"
│ downloaded = "4.163 KiB"
│ remaining = "∞ B"
└ total = "∞ B"
"/home/iamtejas/Downloads/InternshipsToApplyFor-Sheet1.csv"

Downloading a ZIP file from Drive using the `google_download` function
```
julia> google_download("https://drive.google.com/file/d/0B9w48e1rj-MOLVdZRzFfTlNsem8/view", "file.zip")
"/home/iamtejas/Downloads/file.zip"
```

### sheet_handler
`sheet_handler(long_url)`

Provide URL that can be use as link for registering in Datadeps
### google_download_url

### google_download
`google_download(URL, localdir)`
Convert a direct Google Drive / Google Sheets URL to the direct download form.

It can also be consider as "maybe google download function"
The function can be used to download file from google-drive,google-sheets or HTTP download method
#### Example
```
julia>google_download("https://docs.google.com/spreadsheets/d/1tbNIGxnp8wLk31DIMNPD_Hi_CmIdpdTPfzMUDcs1xE/edit#gid=0","/home/iamtejas/Downloads")
┌ Info: Downloading
│ source = "https://docs.google.com/spreadsheets/d/1tbNI-Gxnp8wLk31DIMNPD_Hi_CmIdpdTPfzMUDcs1xE/export?format=csv"
│ dest = "/home/iamtejas/Downloads/InternshipsToApplyFor-Sheet1.csv"
│ progress = NaN
│ time_taken = "0.05 s"
│ time_remaining = "NaN s"
│ average_speed = "84.961 KiB/s"
│ downloaded = "4.163 KiB"
│ remaining = "∞ B"
└ total = "∞ B"
"/home/iamtejas/Downloads/InternshipsToApplyFor-Sheet1.csv"

```
julia> google_download_url("https://drive.google.com/file/d/0B9w48e1rj-MOLVdZRzFfTlNsem8/view")
"https://docs.google.com/uc?export=download&id=0B9w48e1rj-MOLVdZRzFfTlNsem8"
```
3 changes: 1 addition & 2 deletions docs/src/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
```
## Preface

This manual is designed to get you started using GoogleDrive.jl Package in julia in Julia.
It assumes that you already familiar with the basic of [datadeps](https://white.ucc.asn.au/DataDeps.jl/stable/index.html).
This manual is designed to get you started using GoogleDrive.jl Package in Julia.

## Installation

Expand Down
Loading

2 comments on commit 033063a

@JeffFessler
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator() register

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/96879

Tip: Release Notes

Did you know you can add release notes too? Just add markdown formatted text underneath the comment after the text
"Release notes:" and it will be added to the registry PR, and if TagBot is installed it will also be added to the
release that TagBot creates. i.e.

@JuliaRegistrator register

Release notes:

## Breaking changes

- blah

To add them here just re-invoke and the PR will be updated.

Tagging

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.2.0 -m "<description of version>" 033063abc99b7b11536330e872778440df3af1ac
git push origin v0.2.0

Please sign in to comment.