Skip to content

Commit

Permalink
Merge pull request #1296 from burnash/alias/get_values
Browse files Browse the repository at this point in the history
Make `get_values` and alias of `get`
  • Loading branch information
alifeee authored Nov 5, 2023
2 parents 603fae9 + ddd46db commit 6944c1f
Show file tree
Hide file tree
Showing 10 changed files with 3,353 additions and 173 deletions.
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

0 comments on commit 6944c1f

Please sign in to comment.