Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make get_values and alias of get #1296

Merged
merged 34 commits into from
Nov 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
b7b4cd9
alias get_values to call get
alifeee Sep 10, 2023
d7a1d7d
fill blanks in worksheet_test
alifeee Sep 10, 2023
20df26a
rearrange get arguments in worksheet_test
alifeee Sep 10, 2023
4053fac
allow ValueRange constructor to take in values
alifeee Sep 10, 2023
fc97d96
ensure ValueRange metadata is held
alifeee Sep 10, 2023
f118ad6
add test_get_returns_ValueRange_with_metadata
alifeee Sep 10, 2023
cb08726
export ValueRange from gspread
alifeee Sep 10, 2023
b946836
add test cassette
alifeee Sep 10, 2023
51f8e8c
undo changes to `from_json` by...
alifeee Sep 20, 2023
d216069
undo changes to from_json
alifeee Sep 21, 2023
2799068
Merge branch 'feature/release_6_0_0' into alias/get_values
alifeee Oct 19, 2023
192877e
add "GridRangeType" enum
alifeee Oct 19, 2023
63b6197
allow `get` to pad_values and change return type via kwargs
alifeee Oct 19, 2023
d882420
make `get_values` call `get` with default kwargs
alifeee Oct 19, 2023
a358884
undo test changes
alifeee Oct 19, 2023
65581f6
change args in arg test to match kwargs
alifeee Oct 19, 2023
8b49b29
assert `get` behaviour
alifeee Oct 19, 2023
107c1c4
assert `get_values` behaviour
alifeee Oct 19, 2023
fd43b27
test cassettes
alifeee Oct 19, 2023
ddf3db6
`tox -e format`
alifeee Oct 19, 2023
53d5428
fiddle method signature around a bit
alifeee Oct 19, 2023
d342365
change lambda function to dict
alifeee Oct 19, 2023
e46f75b
Merge branch 'feature/release_6_0_0' into alias/get_values
alifeee Oct 28, 2023
0de1239
add test for fill_gaps for non-rectangular array
alifeee Oct 28, 2023
dea0e47
replace readme references of `get_values` with `get`
alifeee Oct 28, 2023
602f6ed
alter get_values test
alifeee Oct 28, 2023
6627b53
tox -e format 🙄
alifeee Oct 28, 2023
da058b8
add test_get_and_get_values_have_same_signature
alifeee Oct 19, 2023
92a4f7e
allow get_values to emulate get
alifeee Oct 31, 2023
a0db203
Revert "add test_get_and_get_values_have_same_signature"
alifeee Oct 31, 2023
91d31f9
add test_get_and_get_values_have_same_signature
alifeee Oct 19, 2023
da10320
make signature test better
alifeee Oct 31, 2023
f46c2c3
make arrguments explicit in get_values...
alifeee Oct 31, 2023
ddd46db
tox -e format
alifeee Oct 31, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 14 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -171,22 +171,30 @@ values_list = worksheet.col_values(1)
### Getting All Values From a Worksheet as a List of Lists

```python
list_of_lists = worksheet.get_values()
from gspread.utils import GridRangeType
list_of_lists = worksheet.get(return_type=GridRangeType.ListOfLists)
```

### Getting a range of values

Receive only the cells with a value in them
Receive only the cells with a value in them.

```python
>>> worksheet.get_values("A1:B4")
>>> worksheet.get("A1:B4")
[['A1', 'B1'], ['A2']]
```

Receive a lists of lists matching the requested size
regardless if values are empty or not
Receive a rectangular array around the cells with values in them.

```python
>>> worksheet.get("A1:B4", pad_values=True)
[['A1', 'B1'], ['A2', '']]
```

Receive an array matching the request size regardless of if values are empty or not.

```python
>>> worksheet.get_values("A1:B4", maintain_size=True)
>>> worksheet.get("A1:B4", maintain_size=True)
[['A1', 'B1'], ['A2', ''], ['', ''], ['', '']]
```

Expand Down
2 changes: 1 addition & 1 deletion gspread/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@
)
from .http_client import BackOffHTTPClient, HTTPClient
from .spreadsheet import Spreadsheet
from .worksheet import Worksheet
from .worksheet import ValueRange, Worksheet
5 changes: 5 additions & 0 deletions gspread/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,11 @@ class PasteOrientation(StrEnum):
transpose = "TRANSPOSE"


class GridRangeType(StrEnum):
ValueRange = "ValueRange"
ListOfLists = "ListOfLists"


def convert_credentials(credentials: Credentials) -> Credentials:
module = credentials.__module__
cls = credentials.__class__.__name__
Expand Down
Loading