MCPcopy
hub / github.com/burnash/gspread / get_notes

Method get_notes

gspread/worksheet.py:2655–2717  ·  view source on GitHub ↗

Returns a list of lists containing all notes in the sheet or range. .. note:: The resulting matrix is not necessarily square. The matrix is as tall as the last row with a note, and each row is only as long as the last column in that row with a note.

(
        self,
        default_empty_value: Optional[str] = "",
        grid_range: Optional[str] = None,
    )

Source from the content-addressed store, hash-verified

2653 return self.client.batch_update(self.spreadsheet_id, {"requests": requests})
2654
2655 def get_notes(
2656 self,
2657 default_empty_value: Optional[str] = "",
2658 grid_range: Optional[str] = None,
2659 ) -> List[List[str]]:
2660 """Returns a list of lists containing all notes in the sheet or range.
2661
2662 .. note::
2663
2664 The resulting matrix is not necessarily square.
2665 The matrix is as tall as the last row with a note,
2666 and each row is only as long as the last column in that row with a note.
2667
2668
2669 Please see the example below.
2670 To ensure it is square, use `gspread.utils.fill_gaps`,
2671 for example like `utils.fill_gaps(arr, len(arr), max(len(a) for a in arr), None)`
2672
2673 :param str default_empty_value: (optional) Determines which value to use
2674 for cells without notes, defaults to None.
2675 :param str grid_range: (optional) Range name in A1 notation, e.g. 'A1:A5'.
2676
2677 Examples::
2678
2679 # Note data:
2680 # A B
2681 # 1 A1 -
2682 # 2 - B2
2683
2684 # Read all notes from the sheet
2685 >>> worksheet.get_notes()
2686 [
2687 ["A1"],
2688 ["", "B2"]
2689 ]
2690 >>> arr = worksheet.get_notes()
2691 >>> gspread.utils.fill_gaps(arr, len(arr), max(len(a) for a in arr), None)
2692 [
2693 ["A1", ""],
2694 ["", "B2"]
2695 ]
2696 # Read notes from a specific range
2697 >>> worksheet.get_notes(grid_range="A2:B2")
2698 [
2699 ["", "B2"]
2700 ]
2701 """
2702 params: ParamsType = {
2703 "fields": "sheets.data.rowData.values.note",
2704 "ranges": absolute_range_name(self.title, grid_range),
2705 }
2706
2707 res = self.client.spreadsheets_get(self.spreadsheet_id, params)
2708
2709 # access 0th sheet because we specified a sheet with params["ranges"] above
2710 data = res["sheets"][0]["data"][0].get("rowData", [{}])
2711 notes: List[List[str]] = []
2712 for row in data:

Callers 2

test_get_notesMethod · 0.80

Calls 3

absolute_range_nameFunction · 0.85
spreadsheets_getMethod · 0.80
getMethod · 0.80

Tested by 2

test_get_notesMethod · 0.64