Skip to content

Commit

Permalink
reverted all changes made by @alifeee
Browse files Browse the repository at this point in the history
  • Loading branch information
muddi900 authored Jul 4, 2024
1 parent 1368fba commit 5951c46
Show file tree
Hide file tree
Showing 4 changed files with 1,268 additions and 2,223 deletions.
32 changes: 24 additions & 8 deletions gspread/worksheet.py
Original file line number Diff line number Diff line change
Expand Up @@ -2607,7 +2607,9 @@ def unmerge_cells(self, name: str) -> JSONResponse:
return self.client.batch_update(self.spreadsheet_id, body)

def get_notes(
self, default_empty_value: Optional[str] = "", range: Optional[str] = None
self,
default_empty_value: Optional[str] = "",
grid_range: Optional[str] = None,
) -> List[List[str]]:
"""Returns a list of lists containing all notes in the sheet or range.
Expand All @@ -2624,6 +2626,7 @@ def get_notes(
:param str default_empty_value: (optional) Determines which value to use
for cells without notes, defaults to None.
:param str grid_range: (optional) Range name in A1 notation, e.g. 'A1:A5'.
Examples::
Expand All @@ -2633,23 +2636,36 @@ def get_notes(
# 2 - B2
# Read all notes from the sheet
>>> arr = worksheet.get_notes()
>>> print(arr)
>>> worksheet.get_notes()
[
["A1"],
["", "B2"]
]
>>> print(gspread.utils.fill_gaps(arr, len(arr), max(len(a) for a in arr), None))
>>> arr = worksheet.get_notes()
>>> gspread.utils.fill_gaps(arr, len(arr), max(len(a) for a in arr), None)
[
["A1", ""],
["", "B2"]
]
# Read notes from a specific range
>>> worksheet.get_notes(grid_range="A2:B2")
[
["", "B2"]
]
"""
params: ParamsType = {"fields": "sheets.data.rowData.values.note"}
if range is not None:
params["ranges"] = absolute_range_name(self.title, range)
params: ParamsType = {
"fields": "sheets.data.rowData.values.note",
"ranges": (
self.title
if grid_range is None
else absolute_range_name(self.title, grid_range)
),
}

res = self.client.spreadsheets_get(self.spreadsheet_id, params)
data = res["sheets"][self.index]["data"][0].get("rowData", [{}])

# access 0th sheet because we specified a sheet with params["ranges"] above
data = res["sheets"][0]["data"][0].get("rowData", [{}])
notes: List[List[str]] = []
for row in data:
notes.append([])
Expand Down
Loading

0 comments on commit 5951c46

Please sign in to comment.