From 4acfac0d8ec99f3bde0f29ec8c77d75aeecf7ac6 Mon Sep 17 00:00:00 2001 From: alifeee Date: Thu, 28 Sep 2023 23:15:53 +0100 Subject: [PATCH 1/9] add regex to match "A2:C5" etc --- gspread/utils.py | 1 + 1 file changed, 1 insertion(+) diff --git a/gspread/utils.py b/gspread/utils.py index eb049eec9..7779de6e7 100644 --- a/gspread/utils.py +++ b/gspread/utils.py @@ -24,6 +24,7 @@ MAGIC_NUMBER = 64 CELL_ADDR_RE = re.compile(r"([A-Za-z]+)([1-9]\d*)") A1_ADDR_ROW_COL_RE = re.compile(r"([A-Za-z]+)?([1-9]\d*)?$") +A1_ADDR_FULL_RE = re.compile(r"[A-Za-z]+\d+:[A-Za-z]+\d+") # e.g. A1:B2 not A1:B URL_KEY_V1_RE = re.compile(r"key=([^&#]+)") URL_KEY_V2_RE = re.compile(r"/spreadsheets/d/([a-zA-Z0-9-_]+)") From 2380ca4ba674d883750b51cbae976df03dd0a494 Mon Sep 17 00:00:00 2001 From: alifeee Date: Thu, 28 Sep 2023 23:17:07 +0100 Subject: [PATCH 2/9] add `utils.is_full_a1_notation` and test "A1:B2" -> True "Sheet1!A1:B2" -> True "A1:B" -> False "4:7" -> False --- gspread/utils.py | 23 +++++++++++++++++++++++ tests/utils_test.py | 16 ++++++++++++++++ 2 files changed, 39 insertions(+) diff --git a/gspread/utils.py b/gspread/utils.py index 7779de6e7..44d1f7bbb 100644 --- a/gspread/utils.py +++ b/gspread/utils.py @@ -868,6 +868,29 @@ def to_hex(value: float) -> str: return f"#{to_hex(red)}{to_hex(green)}{to_hex(blue)}" +def is_full_a1_notation(range_name: str) -> bool: + """Check if the range name is a full A1 notation. + "A1:B2", "Sheet1!A1:B2" are full A1 notations + "A1:B", "A1" are not + + Args: + range_name (str): The range name to check. + + Returns: + bool: True if the range name is a full A1 notation, False otherwise. + + Examples: + + >>> is_full_a1_notation("A1:B2") + True + + >>> is_full_a1_notation("A1:B") + False + """ + if A1_ADDR_FULL_RE.search(range_name): + return True + return False + if __name__ == "__main__": import doctest diff --git a/tests/utils_test.py b/tests/utils_test.py index c49f6c47d..18580af97 100644 --- a/tests/utils_test.py +++ b/tests/utils_test.py @@ -399,3 +399,19 @@ def sample_arg2(arg0, arg1=None, **kwargs): self.assertEqual(kwargs["arg2"], expected_arg2) sample_arg2(0, arg1=1, arg2=2) + + def test_is_full_a1_notation(self): + """test is_full_a1_notation function""" + self.assertTrue(utils.is_full_a1_notation("A1:B2")) + self.assertTrue(utils.is_full_a1_notation("Sheet1!A1:B2")) + self.assertTrue(utils.is_full_a1_notation("AZ1:BBY2")) + self.assertTrue(utils.is_full_a1_notation("AZ142:BBY122")) + + self.assertFalse(utils.is_full_a1_notation("Sheet1")) + self.assertFalse(utils.is_full_a1_notation("A:B")) + self.assertFalse(utils.is_full_a1_notation("1:2")) + self.assertFalse(utils.is_full_a1_notation("1:")) + self.assertFalse(utils.is_full_a1_notation("A1")) + self.assertFalse(utils.is_full_a1_notation("A")) + self.assertFalse(utils.is_full_a1_notation("1")) + self.assertFalse(utils.is_full_a1_notation("")) From ffe5b2e50cc50355f574be2aaa0cb46f8aae029a Mon Sep 17 00:00:00 2001 From: alifeee Date: Thu, 28 Sep 2023 23:17:50 +0100 Subject: [PATCH 3/9] add `utils.get_a1_from_absolute_range` and test basically removes "!" from range "Sheet1!A1:B2" -> "A1:B2" "A1:B2" -> "A1:B2" --- gspread/utils.py | 17 +++++++++++++++++ tests/utils_test.py | 9 +++++++++ 2 files changed, 26 insertions(+) diff --git a/gspread/utils.py b/gspread/utils.py index 44d1f7bbb..5805ea99d 100644 --- a/gspread/utils.py +++ b/gspread/utils.py @@ -891,6 +891,23 @@ def is_full_a1_notation(range_name: str) -> bool: return True return False + +def get_a1_from_absolute_range(range_name: str) -> str: + """Get the A1 notation from an absolute range name. + "Sheet1!A1:B2" -> "A1:B2" + "A1:B2" -> "A1:B2" + + Args: + range_name (str): The range name to check. + + Returns: + str: The A1 notation of the range name stripped of the sheet. + """ + if "!" in range_name: + return range_name.split("!")[1] + return range_name + + if __name__ == "__main__": import doctest diff --git a/tests/utils_test.py b/tests/utils_test.py index 18580af97..5da73b36f 100644 --- a/tests/utils_test.py +++ b/tests/utils_test.py @@ -415,3 +415,12 @@ def test_is_full_a1_notation(self): self.assertFalse(utils.is_full_a1_notation("A")) self.assertFalse(utils.is_full_a1_notation("1")) self.assertFalse(utils.is_full_a1_notation("")) + + def test_get_a1_from_absolute_range(self): + """test get_a1_from_absolute_range function""" + self.assertEqual(utils.get_a1_from_absolute_range("'Sheet1'!A1:B2"), "A1:B2") + self.assertEqual(utils.get_a1_from_absolute_range("'Sheet1'!A1:B"), "A1:B") + self.assertEqual(utils.get_a1_from_absolute_range("Sheet1!A1:B2"), "A1:B2") + self.assertEqual(utils.get_a1_from_absolute_range("A1:B2"), "A1:B2") + self.assertEqual(utils.get_a1_from_absolute_range("A1:B"), "A1:B") + self.assertEqual(utils.get_a1_from_absolute_range("2"), "2") From 7f250596258d1f0f7240c7c799ec238948762094 Mon Sep 17 00:00:00 2001 From: alifeee Date: Thu, 28 Sep 2023 23:18:34 +0100 Subject: [PATCH 4/9] add `maintain_size` kwarg to `get` and `get_values` --- gspread/worksheet.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/gspread/worksheet.py b/gspread/worksheet.py index c5d7a02a5..aed601c97 100644 --- a/gspread/worksheet.py +++ b/gspread/worksheet.py @@ -32,6 +32,8 @@ fill_gaps, filter_dict_values, finditem, + get_a1_from_absolute_range, + is_full_a1_notation, is_scalar, numericise_all, rowcol_to_a1, @@ -366,6 +368,7 @@ def range(self, name=""): combine_merged_cells=False, value_render_option=None, date_time_render_option=None, + maintain_size=False, ) def get_values(self, range_name=None, combine_merged_cells=False, **kwargs): """Returns a list of lists containing all values from specified range. @@ -898,6 +901,7 @@ def update_cells(self, cell_list, value_input_option=ValueInputOption.raw): major_dimension=None, value_render_option=None, date_time_render_option=None, + maintain_size=False, ) def get(self, range_name=None, **kwargs): """Reads values of a single range or a cell of a sheet. @@ -985,6 +989,21 @@ def get(self, range_name=None, **kwargs): response = self.spreadsheet.values_get(range_name, params=params) + values = response.get("values", []) + + if kwargs["maintain_size"] is True and is_full_a1_notation(range_name): + a1_range = get_a1_from_absolute_range(range_name) + grid_range = a1_range_to_grid_range(a1_range) + rows = grid_range.get("endRowIndex", self.row_count) - grid_range.get( + "startRowIndex", 0 + ) + cols = grid_range.get("endColumnIndex", self.col_count) - grid_range.get( + "startColumnIndex", 0 + ) + values = fill_gaps(values, rows=rows, cols=cols) + + response["values"] = values + return ValueRange.from_json(response) @accepted_kwargs( From c9f2ad4e110094ecc726ac280d018d1d8f80ccf0 Mon Sep 17 00:00:00 2001 From: alifeee Date: Thu, 28 Sep 2023 23:18:44 +0100 Subject: [PATCH 5/9] add `test_get_values_and_maintain_size` --- ...est.test_get_values_and_maintain_size.json | 1826 +++++++++++++++++ .../WorksheetTest.test_update_acell.json | 528 +++++ tests/worksheet_test.py | 25 + 3 files changed, 2379 insertions(+) create mode 100644 tests/cassettes/WorksheetTest.test_get_values_and_maintain_size.json diff --git a/tests/cassettes/WorksheetTest.test_get_values_and_maintain_size.json b/tests/cassettes/WorksheetTest.test_get_values_and_maintain_size.json new file mode 100644 index 000000000..c32f297ec --- /dev/null +++ b/tests/cassettes/WorksheetTest.test_get_values_and_maintain_size.json @@ -0,0 +1,1826 @@ +{ + "version": 1, + "interactions": [ + { + "request": { + "method": "POST", + "uri": "https://www.googleapis.com/drive/v3/files?supportsAllDrives=True", + "body": "{\"name\": \"Test WorksheetTest test_get_values_and_maintain_size\", \"mimeType\": \"application/vnd.google-apps.spreadsheet\"}", + "headers": { + "User-Agent": [ + "python-requests/2.31.0" + ], + "Accept-Encoding": [ + "gzip, deflate" + ], + "Accept": [ + "*/*" + ], + "Connection": [ + "keep-alive" + ], + "Content-Length": [ + "119" + ], + "Content-Type": [ + "application/json" + ], + "authorization": [ + "" + ] + } + }, + "response": { + "status": { + "code": 200, + "message": "OK" + }, + "headers": { + "Expires": [ + "Mon, 01 Jan 1990 00:00:00 GMT" + ], + "Alt-Svc": [ + "h3=\":443\"; ma=2592000,h3-29=\":443\"; ma=2592000" + ], + "Pragma": [ + "no-cache" + ], + "X-Content-Type-Options": [ + "nosniff" + ], + "Transfer-Encoding": [ + "chunked" + ], + "X-Frame-Options": [ + "SAMEORIGIN" + ], + "Content-Type": [ + "application/json; charset=UTF-8" + ], + "X-XSS-Protection": [ + "0" + ], + "Server": [ + "ESF" + ], + "Vary": [ + "Origin, X-Origin" + ], + "Cache-Control": [ + "no-cache, no-store, max-age=0, must-revalidate" + ], + "Date": [ + "Thu, 28 Sep 2023 22:04:21 GMT" + ], + "content-length": [ + "206" + ] + }, + "body": { + "string": "{\n \"kind\": \"drive#file\",\n \"id\": \"1isjIvfE6VcLoGetPdHh7PlWSUonG863facctXoVxj0c\",\n \"name\": \"Test WorksheetTest test_get_values_and_maintain_size\",\n \"mimeType\": \"application/vnd.google-apps.spreadsheet\"\n}\n" + } + } + }, + { + "request": { + "method": "GET", + "uri": "https://sheets.googleapis.com/v4/spreadsheets/1isjIvfE6VcLoGetPdHh7PlWSUonG863facctXoVxj0c?includeGridData=false", + "body": null, + "headers": { + "User-Agent": [ + "python-requests/2.31.0" + ], + "Accept-Encoding": [ + "gzip, deflate" + ], + "Accept": [ + "*/*" + ], + "Connection": [ + "keep-alive" + ], + "authorization": [ + "" + ] + } + }, + "response": { + "status": { + "code": 200, + "message": "OK" + }, + "headers": { + "Alt-Svc": [ + "h3=\":443\"; ma=2592000,h3-29=\":443\"; ma=2592000" + ], + "X-Content-Type-Options": [ + "nosniff" + ], + "x-l2-request-path": [ + "l2-managed-6" + ], + "Transfer-Encoding": [ + "chunked" + ], + "X-Frame-Options": [ + "SAMEORIGIN" + ], + "Content-Type": [ + "application/json; charset=UTF-8" + ], + "X-XSS-Protection": [ + "0" + ], + "Server": [ + "ESF" + ], + "Vary": [ + "Origin", + "X-Origin", + "Referer" + ], + "Cache-Control": [ + "private" + ], + "Date": [ + "Thu, 28 Sep 2023 22:04:21 GMT" + ], + "content-length": [ + "3350" + ] + }, + "body": { + "string": "{\n \"spreadsheetId\": \"1isjIvfE6VcLoGetPdHh7PlWSUonG863facctXoVxj0c\",\n \"properties\": {\n \"title\": \"Test WorksheetTest test_get_values_and_maintain_size\",\n \"locale\": \"en_US\",\n \"autoRecalc\": \"ON_CHANGE\",\n \"timeZone\": \"Etc/GMT\",\n \"defaultFormat\": {\n \"backgroundColor\": {\n \"red\": 1,\n \"green\": 1,\n \"blue\": 1\n },\n \"padding\": {\n \"top\": 2,\n \"right\": 3,\n \"bottom\": 2,\n \"left\": 3\n },\n \"verticalAlignment\": \"BOTTOM\",\n \"wrapStrategy\": \"OVERFLOW_CELL\",\n \"textFormat\": {\n \"foregroundColor\": {},\n \"fontFamily\": \"arial,sans,sans-serif\",\n \"fontSize\": 10,\n \"bold\": false,\n \"italic\": false,\n \"strikethrough\": false,\n \"underline\": false,\n \"foregroundColorStyle\": {\n \"rgbColor\": {}\n }\n },\n \"backgroundColorStyle\": {\n \"rgbColor\": {\n \"red\": 1,\n \"green\": 1,\n \"blue\": 1\n }\n }\n },\n \"spreadsheetTheme\": {\n \"primaryFontFamily\": \"Arial\",\n \"themeColors\": [\n {\n \"colorType\": \"TEXT\",\n \"color\": {\n \"rgbColor\": {}\n }\n },\n {\n \"colorType\": \"BACKGROUND\",\n \"color\": {\n \"rgbColor\": {\n \"red\": 1,\n \"green\": 1,\n \"blue\": 1\n }\n }\n },\n {\n \"colorType\": \"ACCENT1\",\n \"color\": {\n \"rgbColor\": {\n \"red\": 0.25882354,\n \"green\": 0.52156866,\n \"blue\": 0.95686275\n }\n }\n },\n {\n \"colorType\": \"ACCENT2\",\n \"color\": {\n \"rgbColor\": {\n \"red\": 0.91764706,\n \"green\": 0.2627451,\n \"blue\": 0.20784314\n }\n }\n },\n {\n \"colorType\": \"ACCENT3\",\n \"color\": {\n \"rgbColor\": {\n \"red\": 0.9843137,\n \"green\": 0.7372549,\n \"blue\": 0.015686275\n }\n }\n },\n {\n \"colorType\": \"ACCENT4\",\n \"color\": {\n \"rgbColor\": {\n \"red\": 0.20392157,\n \"green\": 0.65882355,\n \"blue\": 0.3254902\n }\n }\n },\n {\n \"colorType\": \"ACCENT5\",\n \"color\": {\n \"rgbColor\": {\n \"red\": 1,\n \"green\": 0.42745098,\n \"blue\": 0.003921569\n }\n }\n },\n {\n \"colorType\": \"ACCENT6\",\n \"color\": {\n \"rgbColor\": {\n \"red\": 0.27450982,\n \"green\": 0.7411765,\n \"blue\": 0.7764706\n }\n }\n },\n {\n \"colorType\": \"LINK\",\n \"color\": {\n \"rgbColor\": {\n \"red\": 0.06666667,\n \"green\": 0.33333334,\n \"blue\": 0.8\n }\n }\n }\n ]\n }\n },\n \"sheets\": [\n {\n \"properties\": {\n \"sheetId\": 0,\n \"title\": \"Sheet1\",\n \"index\": 0,\n \"sheetType\": \"GRID\",\n \"gridProperties\": {\n \"rowCount\": 1000,\n \"columnCount\": 26\n }\n }\n }\n ],\n \"spreadsheetUrl\": \"https://docs.google.com/spreadsheets/d/1isjIvfE6VcLoGetPdHh7PlWSUonG863facctXoVxj0c/edit\"\n}\n" + } + } + }, + { + "request": { + "method": "GET", + "uri": "https://sheets.googleapis.com/v4/spreadsheets/1isjIvfE6VcLoGetPdHh7PlWSUonG863facctXoVxj0c?includeGridData=false", + "body": null, + "headers": { + "User-Agent": [ + "python-requests/2.31.0" + ], + "Accept-Encoding": [ + "gzip, deflate" + ], + "Accept": [ + "*/*" + ], + "Connection": [ + "keep-alive" + ], + "authorization": [ + "" + ] + } + }, + "response": { + "status": { + "code": 200, + "message": "OK" + }, + "headers": { + "Alt-Svc": [ + "h3=\":443\"; ma=2592000,h3-29=\":443\"; ma=2592000" + ], + "X-Content-Type-Options": [ + "nosniff" + ], + "x-l2-request-path": [ + "l2-managed-6" + ], + "Transfer-Encoding": [ + "chunked" + ], + "X-Frame-Options": [ + "SAMEORIGIN" + ], + "Content-Type": [ + "application/json; charset=UTF-8" + ], + "X-XSS-Protection": [ + "0" + ], + "Server": [ + "ESF" + ], + "Vary": [ + "Origin", + "X-Origin", + "Referer" + ], + "Cache-Control": [ + "private" + ], + "Date": [ + "Thu, 28 Sep 2023 22:04:22 GMT" + ], + "content-length": [ + "3350" + ] + }, + "body": { + "string": "{\n \"spreadsheetId\": \"1isjIvfE6VcLoGetPdHh7PlWSUonG863facctXoVxj0c\",\n \"properties\": {\n \"title\": \"Test WorksheetTest test_get_values_and_maintain_size\",\n \"locale\": \"en_US\",\n \"autoRecalc\": \"ON_CHANGE\",\n \"timeZone\": \"Etc/GMT\",\n \"defaultFormat\": {\n \"backgroundColor\": {\n \"red\": 1,\n \"green\": 1,\n \"blue\": 1\n },\n \"padding\": {\n \"top\": 2,\n \"right\": 3,\n \"bottom\": 2,\n \"left\": 3\n },\n \"verticalAlignment\": \"BOTTOM\",\n \"wrapStrategy\": \"OVERFLOW_CELL\",\n \"textFormat\": {\n \"foregroundColor\": {},\n \"fontFamily\": \"arial,sans,sans-serif\",\n \"fontSize\": 10,\n \"bold\": false,\n \"italic\": false,\n \"strikethrough\": false,\n \"underline\": false,\n \"foregroundColorStyle\": {\n \"rgbColor\": {}\n }\n },\n \"backgroundColorStyle\": {\n \"rgbColor\": {\n \"red\": 1,\n \"green\": 1,\n \"blue\": 1\n }\n }\n },\n \"spreadsheetTheme\": {\n \"primaryFontFamily\": \"Arial\",\n \"themeColors\": [\n {\n \"colorType\": \"TEXT\",\n \"color\": {\n \"rgbColor\": {}\n }\n },\n {\n \"colorType\": \"BACKGROUND\",\n \"color\": {\n \"rgbColor\": {\n \"red\": 1,\n \"green\": 1,\n \"blue\": 1\n }\n }\n },\n {\n \"colorType\": \"ACCENT1\",\n \"color\": {\n \"rgbColor\": {\n \"red\": 0.25882354,\n \"green\": 0.52156866,\n \"blue\": 0.95686275\n }\n }\n },\n {\n \"colorType\": \"ACCENT2\",\n \"color\": {\n \"rgbColor\": {\n \"red\": 0.91764706,\n \"green\": 0.2627451,\n \"blue\": 0.20784314\n }\n }\n },\n {\n \"colorType\": \"ACCENT3\",\n \"color\": {\n \"rgbColor\": {\n \"red\": 0.9843137,\n \"green\": 0.7372549,\n \"blue\": 0.015686275\n }\n }\n },\n {\n \"colorType\": \"ACCENT4\",\n \"color\": {\n \"rgbColor\": {\n \"red\": 0.20392157,\n \"green\": 0.65882355,\n \"blue\": 0.3254902\n }\n }\n },\n {\n \"colorType\": \"ACCENT5\",\n \"color\": {\n \"rgbColor\": {\n \"red\": 1,\n \"green\": 0.42745098,\n \"blue\": 0.003921569\n }\n }\n },\n {\n \"colorType\": \"ACCENT6\",\n \"color\": {\n \"rgbColor\": {\n \"red\": 0.27450982,\n \"green\": 0.7411765,\n \"blue\": 0.7764706\n }\n }\n },\n {\n \"colorType\": \"LINK\",\n \"color\": {\n \"rgbColor\": {\n \"red\": 0.06666667,\n \"green\": 0.33333334,\n \"blue\": 0.8\n }\n }\n }\n ]\n }\n },\n \"sheets\": [\n {\n \"properties\": {\n \"sheetId\": 0,\n \"title\": \"Sheet1\",\n \"index\": 0,\n \"sheetType\": \"GRID\",\n \"gridProperties\": {\n \"rowCount\": 1000,\n \"columnCount\": 26\n }\n }\n }\n ],\n \"spreadsheetUrl\": \"https://docs.google.com/spreadsheets/d/1isjIvfE6VcLoGetPdHh7PlWSUonG863facctXoVxj0c/edit\"\n}\n" + } + } + }, + { + "request": { + "method": "POST", + "uri": "https://sheets.googleapis.com/v4/spreadsheets/1isjIvfE6VcLoGetPdHh7PlWSUonG863facctXoVxj0c/values/%27Sheet1%27:clear", + "body": null, + "headers": { + "User-Agent": [ + "python-requests/2.31.0" + ], + "Accept-Encoding": [ + "gzip, deflate" + ], + "Accept": [ + "*/*" + ], + "Connection": [ + "keep-alive" + ], + "Content-Length": [ + "0" + ], + "authorization": [ + "" + ] + } + }, + "response": { + "status": { + "code": 200, + "message": "OK" + }, + "headers": { + "Alt-Svc": [ + "h3=\":443\"; ma=2592000,h3-29=\":443\"; ma=2592000" + ], + "X-Content-Type-Options": [ + "nosniff" + ], + "x-l2-request-path": [ + "l2-managed-6" + ], + "Transfer-Encoding": [ + "chunked" + ], + "X-Frame-Options": [ + "SAMEORIGIN" + ], + "Content-Type": [ + "application/json; charset=UTF-8" + ], + "X-XSS-Protection": [ + "0" + ], + "Server": [ + "ESF" + ], + "Vary": [ + "Origin", + "X-Origin", + "Referer" + ], + "Cache-Control": [ + "private" + ], + "Date": [ + "Thu, 28 Sep 2023 22:04:22 GMT" + ], + "content-length": [ + "107" + ] + }, + "body": { + "string": "{\n \"spreadsheetId\": \"1isjIvfE6VcLoGetPdHh7PlWSUonG863facctXoVxj0c\",\n \"clearedRange\": \"Sheet1!A1:Z1000\"\n}\n" + } + } + }, + { + "request": { + "method": "POST", + "uri": "https://sheets.googleapis.com/v4/spreadsheets/1isjIvfE6VcLoGetPdHh7PlWSUonG863facctXoVxj0c:batchUpdate", + "body": "{\"requests\": [{\"updateSheetProperties\": {\"properties\": {\"sheetId\": 0, \"gridProperties\": {\"rowCount\": 5, \"columnCount\": 5}}, \"fields\": \"gridProperties/rowCount,gridProperties/columnCount\"}}]}", + "headers": { + "User-Agent": [ + "python-requests/2.31.0" + ], + "Accept-Encoding": [ + "gzip, deflate" + ], + "Accept": [ + "*/*" + ], + "Connection": [ + "keep-alive" + ], + "Content-Length": [ + "190" + ], + "Content-Type": [ + "application/json" + ], + "authorization": [ + "" + ] + } + }, + "response": { + "status": { + "code": 200, + "message": "OK" + }, + "headers": { + "Alt-Svc": [ + "h3=\":443\"; ma=2592000,h3-29=\":443\"; ma=2592000" + ], + "X-Content-Type-Options": [ + "nosniff" + ], + "x-l2-request-path": [ + "l2-managed-6" + ], + "Transfer-Encoding": [ + "chunked" + ], + "X-Frame-Options": [ + "SAMEORIGIN" + ], + "Content-Type": [ + "application/json; charset=UTF-8" + ], + "X-XSS-Protection": [ + "0" + ], + "Server": [ + "ESF" + ], + "Vary": [ + "Origin", + "X-Origin", + "Referer" + ], + "Cache-Control": [ + "private" + ], + "Date": [ + "Thu, 28 Sep 2023 22:04:22 GMT" + ], + "content-length": [ + "97" + ] + }, + "body": { + "string": "{\n \"spreadsheetId\": \"1isjIvfE6VcLoGetPdHh7PlWSUonG863facctXoVxj0c\",\n \"replies\": [\n {}\n ]\n}\n" + } + } + }, + { + "request": { + "method": "PUT", + "uri": "https://sheets.googleapis.com/v4/spreadsheets/1isjIvfE6VcLoGetPdHh7PlWSUonG863facctXoVxj0c/values/%27Sheet1%27%21A1%3AE5?valueInputOption=RAW", + "body": "{\"values\": [[\"1\", \"2\", \"\", \"\", \"\"], [\"3\", \"4\", \"\", \"\", \"\"], [\"5\", \"6\", \"\", \"\", \"\"], [\"\", \"\", \"\", \"\", \"\"], [\"\", \"\", \"\", \"\", \"\"]]}", + "headers": { + "User-Agent": [ + "python-requests/2.31.0" + ], + "Accept-Encoding": [ + "gzip, deflate" + ], + "Accept": [ + "*/*" + ], + "Connection": [ + "keep-alive" + ], + "Content-Length": [ + "128" + ], + "Content-Type": [ + "application/json" + ], + "authorization": [ + "" + ] + } + }, + "response": { + "status": { + "code": 200, + "message": "OK" + }, + "headers": { + "Alt-Svc": [ + "h3=\":443\"; ma=2592000,h3-29=\":443\"; ma=2592000" + ], + "X-Content-Type-Options": [ + "nosniff" + ], + "x-l2-request-path": [ + "l2-managed-6" + ], + "Transfer-Encoding": [ + "chunked" + ], + "X-Frame-Options": [ + "SAMEORIGIN" + ], + "Content-Type": [ + "application/json; charset=UTF-8" + ], + "X-XSS-Protection": [ + "0" + ], + "Server": [ + "ESF" + ], + "Vary": [ + "Origin", + "X-Origin", + "Referer" + ], + "Cache-Control": [ + "private" + ], + "Date": [ + "Thu, 28 Sep 2023 22:04:23 GMT" + ], + "content-length": [ + "169" + ] + }, + "body": { + "string": "{\n \"spreadsheetId\": \"1isjIvfE6VcLoGetPdHh7PlWSUonG863facctXoVxj0c\",\n \"updatedRange\": \"Sheet1!A1:E5\",\n \"updatedRows\": 5,\n \"updatedColumns\": 5,\n \"updatedCells\": 25\n}\n" + } + } + }, + { + "request": { + "method": "GET", + "uri": "https://sheets.googleapis.com/v4/spreadsheets/1isjIvfE6VcLoGetPdHh7PlWSUonG863facctXoVxj0c/values/%27Sheet1%27%21A1%3AD4", + "body": null, + "headers": { + "User-Agent": [ + "python-requests/2.31.0" + ], + "Accept-Encoding": [ + "gzip, deflate" + ], + "Accept": [ + "*/*" + ], + "Connection": [ + "keep-alive" + ], + "authorization": [ + "" + ] + } + }, + "response": { + "status": { + "code": 200, + "message": "OK" + }, + "headers": { + "Alt-Svc": [ + "h3=\":443\"; ma=2592000,h3-29=\":443\"; ma=2592000" + ], + "X-Content-Type-Options": [ + "nosniff" + ], + "x-l2-request-path": [ + "l2-managed-6" + ], + "Transfer-Encoding": [ + "chunked" + ], + "X-Frame-Options": [ + "SAMEORIGIN" + ], + "Content-Type": [ + "application/json; charset=UTF-8" + ], + "X-XSS-Protection": [ + "0" + ], + "Server": [ + "ESF" + ], + "Vary": [ + "Origin", + "X-Origin", + "Referer" + ], + "Cache-Control": [ + "private" + ], + "Date": [ + "Thu, 28 Sep 2023 22:04:23 GMT" + ], + "content-length": [ + "178" + ] + }, + "body": { + "string": "{\n \"range\": \"Sheet1!A1:D4\",\n \"majorDimension\": \"ROWS\",\n \"values\": [\n [\n \"1\",\n \"2\"\n ],\n [\n \"3\",\n \"4\"\n ],\n [\n \"5\",\n \"6\"\n ]\n ]\n}\n" + } + } + }, + { + "request": { + "method": "DELETE", + "uri": "https://www.googleapis.com/drive/v3/files/1isjIvfE6VcLoGetPdHh7PlWSUonG863facctXoVxj0c?supportsAllDrives=True", + "body": null, + "headers": { + "User-Agent": [ + "python-requests/2.31.0" + ], + "Accept-Encoding": [ + "gzip, deflate" + ], + "Accept": [ + "*/*" + ], + "Connection": [ + "keep-alive" + ], + "Content-Length": [ + "0" + ], + "authorization": [ + "" + ] + } + }, + "response": { + "status": { + "code": 204, + "message": "No Content" + }, + "headers": { + "Expires": [ + "Mon, 01 Jan 1990 00:00:00 GMT" + ], + "Alt-Svc": [ + "h3=\":443\"; ma=2592000,h3-29=\":443\"; ma=2592000" + ], + "Pragma": [ + "no-cache" + ], + "X-Content-Type-Options": [ + "nosniff" + ], + "Content-Length": [ + "0" + ], + "X-Frame-Options": [ + "SAMEORIGIN" + ], + "Content-Type": [ + "text/html" + ], + "X-XSS-Protection": [ + "0" + ], + "Server": [ + "ESF" + ], + "Vary": [ + "Origin, X-Origin" + ], + "Cache-Control": [ + "no-cache, no-store, max-age=0, must-revalidate" + ], + "Date": [ + "Thu, 28 Sep 2023 22:04:24 GMT" + ] + }, + "body": { + "string": "" + } + } + }, + { + "request": { + "method": "POST", + "uri": "https://www.googleapis.com/drive/v3/files?supportsAllDrives=True", + "body": "{\"name\": \"Test WorksheetTest test_get_values_and_maintain_size\", \"mimeType\": \"application/vnd.google-apps.spreadsheet\"}", + "headers": { + "User-Agent": [ + "python-requests/2.31.0" + ], + "Accept-Encoding": [ + "gzip, deflate" + ], + "Accept": [ + "*/*" + ], + "Connection": [ + "keep-alive" + ], + "Content-Length": [ + "119" + ], + "Content-Type": [ + "application/json" + ], + "authorization": [ + "" + ] + } + }, + "response": { + "status": { + "code": 200, + "message": "OK" + }, + "headers": { + "Content-Type": [ + "application/json; charset=UTF-8" + ], + "Cache-Control": [ + "no-cache, no-store, max-age=0, must-revalidate" + ], + "Expires": [ + "Mon, 01 Jan 1990 00:00:00 GMT" + ], + "Vary": [ + "Origin, X-Origin" + ], + "X-XSS-Protection": [ + "0" + ], + "Pragma": [ + "no-cache" + ], + "Alt-Svc": [ + "h3=\":443\"; ma=2592000,h3-29=\":443\"; ma=2592000" + ], + "Server": [ + "ESF" + ], + "Date": [ + "Thu, 28 Sep 2023 22:04:54 GMT" + ], + "X-Frame-Options": [ + "SAMEORIGIN" + ], + "X-Content-Type-Options": [ + "nosniff" + ], + "Transfer-Encoding": [ + "chunked" + ], + "content-length": [ + "206" + ] + }, + "body": { + "string": "{\n \"kind\": \"drive#file\",\n \"id\": \"11sptidmmwmdhW7HBz_LcZ9Mo-jCNTq35qHtmTNHkg80\",\n \"name\": \"Test WorksheetTest test_get_values_and_maintain_size\",\n \"mimeType\": \"application/vnd.google-apps.spreadsheet\"\n}\n" + } + } + }, + { + "request": { + "method": "GET", + "uri": "https://sheets.googleapis.com/v4/spreadsheets/11sptidmmwmdhW7HBz_LcZ9Mo-jCNTq35qHtmTNHkg80?includeGridData=false", + "body": null, + "headers": { + "User-Agent": [ + "python-requests/2.31.0" + ], + "Accept-Encoding": [ + "gzip, deflate" + ], + "Accept": [ + "*/*" + ], + "Connection": [ + "keep-alive" + ], + "authorization": [ + "" + ] + } + }, + "response": { + "status": { + "code": 200, + "message": "OK" + }, + "headers": { + "Content-Type": [ + "application/json; charset=UTF-8" + ], + "x-l2-request-path": [ + "l2-managed-6" + ], + "Cache-Control": [ + "private" + ], + "Vary": [ + "Origin", + "X-Origin", + "Referer" + ], + "X-XSS-Protection": [ + "0" + ], + "Alt-Svc": [ + "h3=\":443\"; ma=2592000,h3-29=\":443\"; ma=2592000" + ], + "Server": [ + "ESF" + ], + "Date": [ + "Thu, 28 Sep 2023 22:04:55 GMT" + ], + "X-Frame-Options": [ + "SAMEORIGIN" + ], + "X-Content-Type-Options": [ + "nosniff" + ], + "Transfer-Encoding": [ + "chunked" + ], + "content-length": [ + "3350" + ] + }, + "body": { + "string": "{\n \"spreadsheetId\": \"11sptidmmwmdhW7HBz_LcZ9Mo-jCNTq35qHtmTNHkg80\",\n \"properties\": {\n \"title\": \"Test WorksheetTest test_get_values_and_maintain_size\",\n \"locale\": \"en_US\",\n \"autoRecalc\": \"ON_CHANGE\",\n \"timeZone\": \"Etc/GMT\",\n \"defaultFormat\": {\n \"backgroundColor\": {\n \"red\": 1,\n \"green\": 1,\n \"blue\": 1\n },\n \"padding\": {\n \"top\": 2,\n \"right\": 3,\n \"bottom\": 2,\n \"left\": 3\n },\n \"verticalAlignment\": \"BOTTOM\",\n \"wrapStrategy\": \"OVERFLOW_CELL\",\n \"textFormat\": {\n \"foregroundColor\": {},\n \"fontFamily\": \"arial,sans,sans-serif\",\n \"fontSize\": 10,\n \"bold\": false,\n \"italic\": false,\n \"strikethrough\": false,\n \"underline\": false,\n \"foregroundColorStyle\": {\n \"rgbColor\": {}\n }\n },\n \"backgroundColorStyle\": {\n \"rgbColor\": {\n \"red\": 1,\n \"green\": 1,\n \"blue\": 1\n }\n }\n },\n \"spreadsheetTheme\": {\n \"primaryFontFamily\": \"Arial\",\n \"themeColors\": [\n {\n \"colorType\": \"TEXT\",\n \"color\": {\n \"rgbColor\": {}\n }\n },\n {\n \"colorType\": \"BACKGROUND\",\n \"color\": {\n \"rgbColor\": {\n \"red\": 1,\n \"green\": 1,\n \"blue\": 1\n }\n }\n },\n {\n \"colorType\": \"ACCENT1\",\n \"color\": {\n \"rgbColor\": {\n \"red\": 0.25882354,\n \"green\": 0.52156866,\n \"blue\": 0.95686275\n }\n }\n },\n {\n \"colorType\": \"ACCENT2\",\n \"color\": {\n \"rgbColor\": {\n \"red\": 0.91764706,\n \"green\": 0.2627451,\n \"blue\": 0.20784314\n }\n }\n },\n {\n \"colorType\": \"ACCENT3\",\n \"color\": {\n \"rgbColor\": {\n \"red\": 0.9843137,\n \"green\": 0.7372549,\n \"blue\": 0.015686275\n }\n }\n },\n {\n \"colorType\": \"ACCENT4\",\n \"color\": {\n \"rgbColor\": {\n \"red\": 0.20392157,\n \"green\": 0.65882355,\n \"blue\": 0.3254902\n }\n }\n },\n {\n \"colorType\": \"ACCENT5\",\n \"color\": {\n \"rgbColor\": {\n \"red\": 1,\n \"green\": 0.42745098,\n \"blue\": 0.003921569\n }\n }\n },\n {\n \"colorType\": \"ACCENT6\",\n \"color\": {\n \"rgbColor\": {\n \"red\": 0.27450982,\n \"green\": 0.7411765,\n \"blue\": 0.7764706\n }\n }\n },\n {\n \"colorType\": \"LINK\",\n \"color\": {\n \"rgbColor\": {\n \"red\": 0.06666667,\n \"green\": 0.33333334,\n \"blue\": 0.8\n }\n }\n }\n ]\n }\n },\n \"sheets\": [\n {\n \"properties\": {\n \"sheetId\": 0,\n \"title\": \"Sheet1\",\n \"index\": 0,\n \"sheetType\": \"GRID\",\n \"gridProperties\": {\n \"rowCount\": 1000,\n \"columnCount\": 26\n }\n }\n }\n ],\n \"spreadsheetUrl\": \"https://docs.google.com/spreadsheets/d/11sptidmmwmdhW7HBz_LcZ9Mo-jCNTq35qHtmTNHkg80/edit\"\n}\n" + } + } + }, + { + "request": { + "method": "GET", + "uri": "https://sheets.googleapis.com/v4/spreadsheets/11sptidmmwmdhW7HBz_LcZ9Mo-jCNTq35qHtmTNHkg80?includeGridData=false", + "body": null, + "headers": { + "User-Agent": [ + "python-requests/2.31.0" + ], + "Accept-Encoding": [ + "gzip, deflate" + ], + "Accept": [ + "*/*" + ], + "Connection": [ + "keep-alive" + ], + "authorization": [ + "" + ] + } + }, + "response": { + "status": { + "code": 200, + "message": "OK" + }, + "headers": { + "Content-Type": [ + "application/json; charset=UTF-8" + ], + "x-l2-request-path": [ + "l2-managed-6" + ], + "Cache-Control": [ + "private" + ], + "Vary": [ + "Origin", + "X-Origin", + "Referer" + ], + "X-XSS-Protection": [ + "0" + ], + "Alt-Svc": [ + "h3=\":443\"; ma=2592000,h3-29=\":443\"; ma=2592000" + ], + "Server": [ + "ESF" + ], + "Date": [ + "Thu, 28 Sep 2023 22:04:55 GMT" + ], + "X-Frame-Options": [ + "SAMEORIGIN" + ], + "X-Content-Type-Options": [ + "nosniff" + ], + "Transfer-Encoding": [ + "chunked" + ], + "content-length": [ + "3350" + ] + }, + "body": { + "string": "{\n \"spreadsheetId\": \"11sptidmmwmdhW7HBz_LcZ9Mo-jCNTq35qHtmTNHkg80\",\n \"properties\": {\n \"title\": \"Test WorksheetTest test_get_values_and_maintain_size\",\n \"locale\": \"en_US\",\n \"autoRecalc\": \"ON_CHANGE\",\n \"timeZone\": \"Etc/GMT\",\n \"defaultFormat\": {\n \"backgroundColor\": {\n \"red\": 1,\n \"green\": 1,\n \"blue\": 1\n },\n \"padding\": {\n \"top\": 2,\n \"right\": 3,\n \"bottom\": 2,\n \"left\": 3\n },\n \"verticalAlignment\": \"BOTTOM\",\n \"wrapStrategy\": \"OVERFLOW_CELL\",\n \"textFormat\": {\n \"foregroundColor\": {},\n \"fontFamily\": \"arial,sans,sans-serif\",\n \"fontSize\": 10,\n \"bold\": false,\n \"italic\": false,\n \"strikethrough\": false,\n \"underline\": false,\n \"foregroundColorStyle\": {\n \"rgbColor\": {}\n }\n },\n \"backgroundColorStyle\": {\n \"rgbColor\": {\n \"red\": 1,\n \"green\": 1,\n \"blue\": 1\n }\n }\n },\n \"spreadsheetTheme\": {\n \"primaryFontFamily\": \"Arial\",\n \"themeColors\": [\n {\n \"colorType\": \"TEXT\",\n \"color\": {\n \"rgbColor\": {}\n }\n },\n {\n \"colorType\": \"BACKGROUND\",\n \"color\": {\n \"rgbColor\": {\n \"red\": 1,\n \"green\": 1,\n \"blue\": 1\n }\n }\n },\n {\n \"colorType\": \"ACCENT1\",\n \"color\": {\n \"rgbColor\": {\n \"red\": 0.25882354,\n \"green\": 0.52156866,\n \"blue\": 0.95686275\n }\n }\n },\n {\n \"colorType\": \"ACCENT2\",\n \"color\": {\n \"rgbColor\": {\n \"red\": 0.91764706,\n \"green\": 0.2627451,\n \"blue\": 0.20784314\n }\n }\n },\n {\n \"colorType\": \"ACCENT3\",\n \"color\": {\n \"rgbColor\": {\n \"red\": 0.9843137,\n \"green\": 0.7372549,\n \"blue\": 0.015686275\n }\n }\n },\n {\n \"colorType\": \"ACCENT4\",\n \"color\": {\n \"rgbColor\": {\n \"red\": 0.20392157,\n \"green\": 0.65882355,\n \"blue\": 0.3254902\n }\n }\n },\n {\n \"colorType\": \"ACCENT5\",\n \"color\": {\n \"rgbColor\": {\n \"red\": 1,\n \"green\": 0.42745098,\n \"blue\": 0.003921569\n }\n }\n },\n {\n \"colorType\": \"ACCENT6\",\n \"color\": {\n \"rgbColor\": {\n \"red\": 0.27450982,\n \"green\": 0.7411765,\n \"blue\": 0.7764706\n }\n }\n },\n {\n \"colorType\": \"LINK\",\n \"color\": {\n \"rgbColor\": {\n \"red\": 0.06666667,\n \"green\": 0.33333334,\n \"blue\": 0.8\n }\n }\n }\n ]\n }\n },\n \"sheets\": [\n {\n \"properties\": {\n \"sheetId\": 0,\n \"title\": \"Sheet1\",\n \"index\": 0,\n \"sheetType\": \"GRID\",\n \"gridProperties\": {\n \"rowCount\": 1000,\n \"columnCount\": 26\n }\n }\n }\n ],\n \"spreadsheetUrl\": \"https://docs.google.com/spreadsheets/d/11sptidmmwmdhW7HBz_LcZ9Mo-jCNTq35qHtmTNHkg80/edit\"\n}\n" + } + } + }, + { + "request": { + "method": "POST", + "uri": "https://sheets.googleapis.com/v4/spreadsheets/11sptidmmwmdhW7HBz_LcZ9Mo-jCNTq35qHtmTNHkg80/values/%27Sheet1%27:clear", + "body": null, + "headers": { + "User-Agent": [ + "python-requests/2.31.0" + ], + "Accept-Encoding": [ + "gzip, deflate" + ], + "Accept": [ + "*/*" + ], + "Connection": [ + "keep-alive" + ], + "Content-Length": [ + "0" + ], + "authorization": [ + "" + ] + } + }, + "response": { + "status": { + "code": 200, + "message": "OK" + }, + "headers": { + "Content-Type": [ + "application/json; charset=UTF-8" + ], + "x-l2-request-path": [ + "l2-managed-6" + ], + "Cache-Control": [ + "private" + ], + "Vary": [ + "Origin", + "X-Origin", + "Referer" + ], + "X-XSS-Protection": [ + "0" + ], + "Alt-Svc": [ + "h3=\":443\"; ma=2592000,h3-29=\":443\"; ma=2592000" + ], + "Server": [ + "ESF" + ], + "Date": [ + "Thu, 28 Sep 2023 22:04:55 GMT" + ], + "X-Frame-Options": [ + "SAMEORIGIN" + ], + "X-Content-Type-Options": [ + "nosniff" + ], + "Transfer-Encoding": [ + "chunked" + ], + "content-length": [ + "107" + ] + }, + "body": { + "string": "{\n \"spreadsheetId\": \"11sptidmmwmdhW7HBz_LcZ9Mo-jCNTq35qHtmTNHkg80\",\n \"clearedRange\": \"Sheet1!A1:Z1000\"\n}\n" + } + } + }, + { + "request": { + "method": "POST", + "uri": "https://sheets.googleapis.com/v4/spreadsheets/11sptidmmwmdhW7HBz_LcZ9Mo-jCNTq35qHtmTNHkg80:batchUpdate", + "body": "{\"requests\": [{\"updateSheetProperties\": {\"properties\": {\"sheetId\": 0, \"gridProperties\": {\"rowCount\": 5, \"columnCount\": 5}}, \"fields\": \"gridProperties/rowCount,gridProperties/columnCount\"}}]}", + "headers": { + "User-Agent": [ + "python-requests/2.31.0" + ], + "Accept-Encoding": [ + "gzip, deflate" + ], + "Accept": [ + "*/*" + ], + "Connection": [ + "keep-alive" + ], + "Content-Length": [ + "190" + ], + "Content-Type": [ + "application/json" + ], + "authorization": [ + "" + ] + } + }, + "response": { + "status": { + "code": 200, + "message": "OK" + }, + "headers": { + "Content-Type": [ + "application/json; charset=UTF-8" + ], + "x-l2-request-path": [ + "l2-managed-6" + ], + "Cache-Control": [ + "private" + ], + "Vary": [ + "Origin", + "X-Origin", + "Referer" + ], + "X-XSS-Protection": [ + "0" + ], + "Alt-Svc": [ + "h3=\":443\"; ma=2592000,h3-29=\":443\"; ma=2592000" + ], + "Server": [ + "ESF" + ], + "Date": [ + "Thu, 28 Sep 2023 22:04:56 GMT" + ], + "X-Frame-Options": [ + "SAMEORIGIN" + ], + "X-Content-Type-Options": [ + "nosniff" + ], + "Transfer-Encoding": [ + "chunked" + ], + "content-length": [ + "97" + ] + }, + "body": { + "string": "{\n \"spreadsheetId\": \"11sptidmmwmdhW7HBz_LcZ9Mo-jCNTq35qHtmTNHkg80\",\n \"replies\": [\n {}\n ]\n}\n" + } + } + }, + { + "request": { + "method": "PUT", + "uri": "https://sheets.googleapis.com/v4/spreadsheets/11sptidmmwmdhW7HBz_LcZ9Mo-jCNTq35qHtmTNHkg80/values/%27Sheet1%27%21A1%3AE5?valueInputOption=RAW", + "body": "{\"values\": [[\"1\", \"2\", \"\", \"\", \"\"], [\"3\", \"4\", \"\", \"\", \"\"], [\"5\", \"6\", \"\", \"\", \"\"], [\"\", \"\", \"\", \"\", \"\"], [\"\", \"\", \"\", \"\", \"\"]]}", + "headers": { + "User-Agent": [ + "python-requests/2.31.0" + ], + "Accept-Encoding": [ + "gzip, deflate" + ], + "Accept": [ + "*/*" + ], + "Connection": [ + "keep-alive" + ], + "Content-Length": [ + "128" + ], + "Content-Type": [ + "application/json" + ], + "authorization": [ + "" + ] + } + }, + "response": { + "status": { + "code": 200, + "message": "OK" + }, + "headers": { + "Content-Type": [ + "application/json; charset=UTF-8" + ], + "x-l2-request-path": [ + "l2-managed-6" + ], + "Cache-Control": [ + "private" + ], + "Vary": [ + "Origin", + "X-Origin", + "Referer" + ], + "X-XSS-Protection": [ + "0" + ], + "Alt-Svc": [ + "h3=\":443\"; ma=2592000,h3-29=\":443\"; ma=2592000" + ], + "Server": [ + "ESF" + ], + "Date": [ + "Thu, 28 Sep 2023 22:04:56 GMT" + ], + "X-Frame-Options": [ + "SAMEORIGIN" + ], + "X-Content-Type-Options": [ + "nosniff" + ], + "Transfer-Encoding": [ + "chunked" + ], + "content-length": [ + "169" + ] + }, + "body": { + "string": "{\n \"spreadsheetId\": \"11sptidmmwmdhW7HBz_LcZ9Mo-jCNTq35qHtmTNHkg80\",\n \"updatedRange\": \"Sheet1!A1:E5\",\n \"updatedRows\": 5,\n \"updatedColumns\": 5,\n \"updatedCells\": 25\n}\n" + } + } + }, + { + "request": { + "method": "GET", + "uri": "https://sheets.googleapis.com/v4/spreadsheets/11sptidmmwmdhW7HBz_LcZ9Mo-jCNTq35qHtmTNHkg80/values/%27Sheet1%27%21A1%3AD4", + "body": null, + "headers": { + "User-Agent": [ + "python-requests/2.31.0" + ], + "Accept-Encoding": [ + "gzip, deflate" + ], + "Accept": [ + "*/*" + ], + "Connection": [ + "keep-alive" + ], + "authorization": [ + "" + ] + } + }, + "response": { + "status": { + "code": 200, + "message": "OK" + }, + "headers": { + "Content-Type": [ + "application/json; charset=UTF-8" + ], + "x-l2-request-path": [ + "l2-managed-6" + ], + "Cache-Control": [ + "private" + ], + "Vary": [ + "Origin", + "X-Origin", + "Referer" + ], + "X-XSS-Protection": [ + "0" + ], + "Alt-Svc": [ + "h3=\":443\"; ma=2592000,h3-29=\":443\"; ma=2592000" + ], + "Server": [ + "ESF" + ], + "Date": [ + "Thu, 28 Sep 2023 22:04:56 GMT" + ], + "X-Frame-Options": [ + "SAMEORIGIN" + ], + "X-Content-Type-Options": [ + "nosniff" + ], + "Transfer-Encoding": [ + "chunked" + ], + "content-length": [ + "178" + ] + }, + "body": { + "string": "{\n \"range\": \"Sheet1!A1:D4\",\n \"majorDimension\": \"ROWS\",\n \"values\": [\n [\n \"1\",\n \"2\"\n ],\n [\n \"3\",\n \"4\"\n ],\n [\n \"5\",\n \"6\"\n ]\n ]\n}\n" + } + } + }, + { + "request": { + "method": "DELETE", + "uri": "https://www.googleapis.com/drive/v3/files/11sptidmmwmdhW7HBz_LcZ9Mo-jCNTq35qHtmTNHkg80?supportsAllDrives=True", + "body": null, + "headers": { + "User-Agent": [ + "python-requests/2.31.0" + ], + "Accept-Encoding": [ + "gzip, deflate" + ], + "Accept": [ + "*/*" + ], + "Connection": [ + "keep-alive" + ], + "Content-Length": [ + "0" + ], + "authorization": [ + "" + ] + } + }, + "response": { + "status": { + "code": 204, + "message": "No Content" + }, + "headers": { + "Content-Type": [ + "text/html" + ], + "Cache-Control": [ + "no-cache, no-store, max-age=0, must-revalidate" + ], + "Expires": [ + "Mon, 01 Jan 1990 00:00:00 GMT" + ], + "Vary": [ + "Origin, X-Origin" + ], + "X-XSS-Protection": [ + "0" + ], + "Pragma": [ + "no-cache" + ], + "Alt-Svc": [ + "h3=\":443\"; ma=2592000,h3-29=\":443\"; ma=2592000" + ], + "Server": [ + "ESF" + ], + "Content-Length": [ + "0" + ], + "Date": [ + "Thu, 28 Sep 2023 22:04:57 GMT" + ], + "X-Frame-Options": [ + "SAMEORIGIN" + ], + "X-Content-Type-Options": [ + "nosniff" + ] + }, + "body": { + "string": "" + } + } + }, + { + "request": { + "method": "POST", + "uri": "https://www.googleapis.com/drive/v3/files?supportsAllDrives=True", + "body": "{\"name\": \"Test WorksheetTest test_get_values_and_maintain_size\", \"mimeType\": \"application/vnd.google-apps.spreadsheet\"}", + "headers": { + "User-Agent": [ + "python-requests/2.31.0" + ], + "Accept-Encoding": [ + "gzip, deflate" + ], + "Accept": [ + "*/*" + ], + "Connection": [ + "keep-alive" + ], + "Content-Length": [ + "119" + ], + "Content-Type": [ + "application/json" + ], + "authorization": [ + "" + ] + } + }, + "response": { + "status": { + "code": 200, + "message": "OK" + }, + "headers": { + "Content-Type": [ + "application/json; charset=UTF-8" + ], + "X-Frame-Options": [ + "SAMEORIGIN" + ], + "Pragma": [ + "no-cache" + ], + "Server": [ + "ESF" + ], + "Transfer-Encoding": [ + "chunked" + ], + "Date": [ + "Thu, 28 Sep 2023 22:12:03 GMT" + ], + "Alt-Svc": [ + "h3=\":443\"; ma=2592000,h3-29=\":443\"; ma=2592000" + ], + "Expires": [ + "Mon, 01 Jan 1990 00:00:00 GMT" + ], + "X-Content-Type-Options": [ + "nosniff" + ], + "X-XSS-Protection": [ + "0" + ], + "Vary": [ + "Origin, X-Origin" + ], + "Cache-Control": [ + "no-cache, no-store, max-age=0, must-revalidate" + ], + "content-length": [ + "206" + ] + }, + "body": { + "string": "{\n \"kind\": \"drive#file\",\n \"id\": \"1OzMP0HH2Jv_kdY815pcsQr8y8XC_W_a08iz-f06-b4A\",\n \"name\": \"Test WorksheetTest test_get_values_and_maintain_size\",\n \"mimeType\": \"application/vnd.google-apps.spreadsheet\"\n}\n" + } + } + }, + { + "request": { + "method": "GET", + "uri": "https://sheets.googleapis.com/v4/spreadsheets/1OzMP0HH2Jv_kdY815pcsQr8y8XC_W_a08iz-f06-b4A?includeGridData=false", + "body": null, + "headers": { + "User-Agent": [ + "python-requests/2.31.0" + ], + "Accept-Encoding": [ + "gzip, deflate" + ], + "Accept": [ + "*/*" + ], + "Connection": [ + "keep-alive" + ], + "authorization": [ + "" + ] + } + }, + "response": { + "status": { + "code": 200, + "message": "OK" + }, + "headers": { + "Content-Type": [ + "application/json; charset=UTF-8" + ], + "x-l2-request-path": [ + "l2-managed-6" + ], + "X-Frame-Options": [ + "SAMEORIGIN" + ], + "Server": [ + "ESF" + ], + "Transfer-Encoding": [ + "chunked" + ], + "Date": [ + "Thu, 28 Sep 2023 22:12:04 GMT" + ], + "Alt-Svc": [ + "h3=\":443\"; ma=2592000,h3-29=\":443\"; ma=2592000" + ], + "X-Content-Type-Options": [ + "nosniff" + ], + "X-XSS-Protection": [ + "0" + ], + "Vary": [ + "Origin", + "X-Origin", + "Referer" + ], + "Cache-Control": [ + "private" + ], + "content-length": [ + "3350" + ] + }, + "body": { + "string": "{\n \"spreadsheetId\": \"1OzMP0HH2Jv_kdY815pcsQr8y8XC_W_a08iz-f06-b4A\",\n \"properties\": {\n \"title\": \"Test WorksheetTest test_get_values_and_maintain_size\",\n \"locale\": \"en_US\",\n \"autoRecalc\": \"ON_CHANGE\",\n \"timeZone\": \"Etc/GMT\",\n \"defaultFormat\": {\n \"backgroundColor\": {\n \"red\": 1,\n \"green\": 1,\n \"blue\": 1\n },\n \"padding\": {\n \"top\": 2,\n \"right\": 3,\n \"bottom\": 2,\n \"left\": 3\n },\n \"verticalAlignment\": \"BOTTOM\",\n \"wrapStrategy\": \"OVERFLOW_CELL\",\n \"textFormat\": {\n \"foregroundColor\": {},\n \"fontFamily\": \"arial,sans,sans-serif\",\n \"fontSize\": 10,\n \"bold\": false,\n \"italic\": false,\n \"strikethrough\": false,\n \"underline\": false,\n \"foregroundColorStyle\": {\n \"rgbColor\": {}\n }\n },\n \"backgroundColorStyle\": {\n \"rgbColor\": {\n \"red\": 1,\n \"green\": 1,\n \"blue\": 1\n }\n }\n },\n \"spreadsheetTheme\": {\n \"primaryFontFamily\": \"Arial\",\n \"themeColors\": [\n {\n \"colorType\": \"TEXT\",\n \"color\": {\n \"rgbColor\": {}\n }\n },\n {\n \"colorType\": \"BACKGROUND\",\n \"color\": {\n \"rgbColor\": {\n \"red\": 1,\n \"green\": 1,\n \"blue\": 1\n }\n }\n },\n {\n \"colorType\": \"ACCENT1\",\n \"color\": {\n \"rgbColor\": {\n \"red\": 0.25882354,\n \"green\": 0.52156866,\n \"blue\": 0.95686275\n }\n }\n },\n {\n \"colorType\": \"ACCENT2\",\n \"color\": {\n \"rgbColor\": {\n \"red\": 0.91764706,\n \"green\": 0.2627451,\n \"blue\": 0.20784314\n }\n }\n },\n {\n \"colorType\": \"ACCENT3\",\n \"color\": {\n \"rgbColor\": {\n \"red\": 0.9843137,\n \"green\": 0.7372549,\n \"blue\": 0.015686275\n }\n }\n },\n {\n \"colorType\": \"ACCENT4\",\n \"color\": {\n \"rgbColor\": {\n \"red\": 0.20392157,\n \"green\": 0.65882355,\n \"blue\": 0.3254902\n }\n }\n },\n {\n \"colorType\": \"ACCENT5\",\n \"color\": {\n \"rgbColor\": {\n \"red\": 1,\n \"green\": 0.42745098,\n \"blue\": 0.003921569\n }\n }\n },\n {\n \"colorType\": \"ACCENT6\",\n \"color\": {\n \"rgbColor\": {\n \"red\": 0.27450982,\n \"green\": 0.7411765,\n \"blue\": 0.7764706\n }\n }\n },\n {\n \"colorType\": \"LINK\",\n \"color\": {\n \"rgbColor\": {\n \"red\": 0.06666667,\n \"green\": 0.33333334,\n \"blue\": 0.8\n }\n }\n }\n ]\n }\n },\n \"sheets\": [\n {\n \"properties\": {\n \"sheetId\": 0,\n \"title\": \"Sheet1\",\n \"index\": 0,\n \"sheetType\": \"GRID\",\n \"gridProperties\": {\n \"rowCount\": 1000,\n \"columnCount\": 26\n }\n }\n }\n ],\n \"spreadsheetUrl\": \"https://docs.google.com/spreadsheets/d/1OzMP0HH2Jv_kdY815pcsQr8y8XC_W_a08iz-f06-b4A/edit\"\n}\n" + } + } + }, + { + "request": { + "method": "GET", + "uri": "https://sheets.googleapis.com/v4/spreadsheets/1OzMP0HH2Jv_kdY815pcsQr8y8XC_W_a08iz-f06-b4A?includeGridData=false", + "body": null, + "headers": { + "User-Agent": [ + "python-requests/2.31.0" + ], + "Accept-Encoding": [ + "gzip, deflate" + ], + "Accept": [ + "*/*" + ], + "Connection": [ + "keep-alive" + ], + "authorization": [ + "" + ] + } + }, + "response": { + "status": { + "code": 200, + "message": "OK" + }, + "headers": { + "Content-Type": [ + "application/json; charset=UTF-8" + ], + "x-l2-request-path": [ + "l2-managed-6" + ], + "X-Frame-Options": [ + "SAMEORIGIN" + ], + "Server": [ + "ESF" + ], + "Transfer-Encoding": [ + "chunked" + ], + "Date": [ + "Thu, 28 Sep 2023 22:12:04 GMT" + ], + "Alt-Svc": [ + "h3=\":443\"; ma=2592000,h3-29=\":443\"; ma=2592000" + ], + "X-Content-Type-Options": [ + "nosniff" + ], + "X-XSS-Protection": [ + "0" + ], + "Vary": [ + "Origin", + "X-Origin", + "Referer" + ], + "Cache-Control": [ + "private" + ], + "content-length": [ + "3350" + ] + }, + "body": { + "string": "{\n \"spreadsheetId\": \"1OzMP0HH2Jv_kdY815pcsQr8y8XC_W_a08iz-f06-b4A\",\n \"properties\": {\n \"title\": \"Test WorksheetTest test_get_values_and_maintain_size\",\n \"locale\": \"en_US\",\n \"autoRecalc\": \"ON_CHANGE\",\n \"timeZone\": \"Etc/GMT\",\n \"defaultFormat\": {\n \"backgroundColor\": {\n \"red\": 1,\n \"green\": 1,\n \"blue\": 1\n },\n \"padding\": {\n \"top\": 2,\n \"right\": 3,\n \"bottom\": 2,\n \"left\": 3\n },\n \"verticalAlignment\": \"BOTTOM\",\n \"wrapStrategy\": \"OVERFLOW_CELL\",\n \"textFormat\": {\n \"foregroundColor\": {},\n \"fontFamily\": \"arial,sans,sans-serif\",\n \"fontSize\": 10,\n \"bold\": false,\n \"italic\": false,\n \"strikethrough\": false,\n \"underline\": false,\n \"foregroundColorStyle\": {\n \"rgbColor\": {}\n }\n },\n \"backgroundColorStyle\": {\n \"rgbColor\": {\n \"red\": 1,\n \"green\": 1,\n \"blue\": 1\n }\n }\n },\n \"spreadsheetTheme\": {\n \"primaryFontFamily\": \"Arial\",\n \"themeColors\": [\n {\n \"colorType\": \"TEXT\",\n \"color\": {\n \"rgbColor\": {}\n }\n },\n {\n \"colorType\": \"BACKGROUND\",\n \"color\": {\n \"rgbColor\": {\n \"red\": 1,\n \"green\": 1,\n \"blue\": 1\n }\n }\n },\n {\n \"colorType\": \"ACCENT1\",\n \"color\": {\n \"rgbColor\": {\n \"red\": 0.25882354,\n \"green\": 0.52156866,\n \"blue\": 0.95686275\n }\n }\n },\n {\n \"colorType\": \"ACCENT2\",\n \"color\": {\n \"rgbColor\": {\n \"red\": 0.91764706,\n \"green\": 0.2627451,\n \"blue\": 0.20784314\n }\n }\n },\n {\n \"colorType\": \"ACCENT3\",\n \"color\": {\n \"rgbColor\": {\n \"red\": 0.9843137,\n \"green\": 0.7372549,\n \"blue\": 0.015686275\n }\n }\n },\n {\n \"colorType\": \"ACCENT4\",\n \"color\": {\n \"rgbColor\": {\n \"red\": 0.20392157,\n \"green\": 0.65882355,\n \"blue\": 0.3254902\n }\n }\n },\n {\n \"colorType\": \"ACCENT5\",\n \"color\": {\n \"rgbColor\": {\n \"red\": 1,\n \"green\": 0.42745098,\n \"blue\": 0.003921569\n }\n }\n },\n {\n \"colorType\": \"ACCENT6\",\n \"color\": {\n \"rgbColor\": {\n \"red\": 0.27450982,\n \"green\": 0.7411765,\n \"blue\": 0.7764706\n }\n }\n },\n {\n \"colorType\": \"LINK\",\n \"color\": {\n \"rgbColor\": {\n \"red\": 0.06666667,\n \"green\": 0.33333334,\n \"blue\": 0.8\n }\n }\n }\n ]\n }\n },\n \"sheets\": [\n {\n \"properties\": {\n \"sheetId\": 0,\n \"title\": \"Sheet1\",\n \"index\": 0,\n \"sheetType\": \"GRID\",\n \"gridProperties\": {\n \"rowCount\": 1000,\n \"columnCount\": 26\n }\n }\n }\n ],\n \"spreadsheetUrl\": \"https://docs.google.com/spreadsheets/d/1OzMP0HH2Jv_kdY815pcsQr8y8XC_W_a08iz-f06-b4A/edit\"\n}\n" + } + } + }, + { + "request": { + "method": "POST", + "uri": "https://sheets.googleapis.com/v4/spreadsheets/1OzMP0HH2Jv_kdY815pcsQr8y8XC_W_a08iz-f06-b4A/values/%27Sheet1%27:clear", + "body": null, + "headers": { + "User-Agent": [ + "python-requests/2.31.0" + ], + "Accept-Encoding": [ + "gzip, deflate" + ], + "Accept": [ + "*/*" + ], + "Connection": [ + "keep-alive" + ], + "Content-Length": [ + "0" + ], + "authorization": [ + "" + ] + } + }, + "response": { + "status": { + "code": 200, + "message": "OK" + }, + "headers": { + "Content-Type": [ + "application/json; charset=UTF-8" + ], + "x-l2-request-path": [ + "l2-managed-6" + ], + "X-Frame-Options": [ + "SAMEORIGIN" + ], + "Server": [ + "ESF" + ], + "Transfer-Encoding": [ + "chunked" + ], + "Date": [ + "Thu, 28 Sep 2023 22:12:04 GMT" + ], + "Alt-Svc": [ + "h3=\":443\"; ma=2592000,h3-29=\":443\"; ma=2592000" + ], + "X-Content-Type-Options": [ + "nosniff" + ], + "X-XSS-Protection": [ + "0" + ], + "Vary": [ + "Origin", + "X-Origin", + "Referer" + ], + "Cache-Control": [ + "private" + ], + "content-length": [ + "107" + ] + }, + "body": { + "string": "{\n \"spreadsheetId\": \"1OzMP0HH2Jv_kdY815pcsQr8y8XC_W_a08iz-f06-b4A\",\n \"clearedRange\": \"Sheet1!A1:Z1000\"\n}\n" + } + } + }, + { + "request": { + "method": "POST", + "uri": "https://sheets.googleapis.com/v4/spreadsheets/1OzMP0HH2Jv_kdY815pcsQr8y8XC_W_a08iz-f06-b4A:batchUpdate", + "body": "{\"requests\": [{\"updateSheetProperties\": {\"properties\": {\"sheetId\": 0, \"gridProperties\": {\"rowCount\": 5, \"columnCount\": 5}}, \"fields\": \"gridProperties/rowCount,gridProperties/columnCount\"}}]}", + "headers": { + "User-Agent": [ + "python-requests/2.31.0" + ], + "Accept-Encoding": [ + "gzip, deflate" + ], + "Accept": [ + "*/*" + ], + "Connection": [ + "keep-alive" + ], + "Content-Length": [ + "190" + ], + "Content-Type": [ + "application/json" + ], + "authorization": [ + "" + ] + } + }, + "response": { + "status": { + "code": 200, + "message": "OK" + }, + "headers": { + "Content-Type": [ + "application/json; charset=UTF-8" + ], + "x-l2-request-path": [ + "l2-managed-6" + ], + "X-Frame-Options": [ + "SAMEORIGIN" + ], + "Server": [ + "ESF" + ], + "Transfer-Encoding": [ + "chunked" + ], + "Date": [ + "Thu, 28 Sep 2023 22:12:04 GMT" + ], + "Alt-Svc": [ + "h3=\":443\"; ma=2592000,h3-29=\":443\"; ma=2592000" + ], + "X-Content-Type-Options": [ + "nosniff" + ], + "X-XSS-Protection": [ + "0" + ], + "Vary": [ + "Origin", + "X-Origin", + "Referer" + ], + "Cache-Control": [ + "private" + ], + "content-length": [ + "97" + ] + }, + "body": { + "string": "{\n \"spreadsheetId\": \"1OzMP0HH2Jv_kdY815pcsQr8y8XC_W_a08iz-f06-b4A\",\n \"replies\": [\n {}\n ]\n}\n" + } + } + }, + { + "request": { + "method": "PUT", + "uri": "https://sheets.googleapis.com/v4/spreadsheets/1OzMP0HH2Jv_kdY815pcsQr8y8XC_W_a08iz-f06-b4A/values/%27Sheet1%27%21A1%3AE5?valueInputOption=RAW", + "body": "{\"values\": [[\"1\", \"2\", \"\", \"\", \"\"], [\"3\", \"4\", \"\", \"\", \"\"], [\"5\", \"6\", \"\", \"\", \"\"], [\"\", \"\", \"\", \"\", \"\"], [\"\", \"\", \"\", \"\", \"\"]]}", + "headers": { + "User-Agent": [ + "python-requests/2.31.0" + ], + "Accept-Encoding": [ + "gzip, deflate" + ], + "Accept": [ + "*/*" + ], + "Connection": [ + "keep-alive" + ], + "Content-Length": [ + "128" + ], + "Content-Type": [ + "application/json" + ], + "authorization": [ + "" + ] + } + }, + "response": { + "status": { + "code": 200, + "message": "OK" + }, + "headers": { + "Content-Type": [ + "application/json; charset=UTF-8" + ], + "x-l2-request-path": [ + "l2-managed-6" + ], + "X-Frame-Options": [ + "SAMEORIGIN" + ], + "Server": [ + "ESF" + ], + "Transfer-Encoding": [ + "chunked" + ], + "Date": [ + "Thu, 28 Sep 2023 22:12:05 GMT" + ], + "Alt-Svc": [ + "h3=\":443\"; ma=2592000,h3-29=\":443\"; ma=2592000" + ], + "X-Content-Type-Options": [ + "nosniff" + ], + "X-XSS-Protection": [ + "0" + ], + "Vary": [ + "Origin", + "X-Origin", + "Referer" + ], + "Cache-Control": [ + "private" + ], + "content-length": [ + "169" + ] + }, + "body": { + "string": "{\n \"spreadsheetId\": \"1OzMP0HH2Jv_kdY815pcsQr8y8XC_W_a08iz-f06-b4A\",\n \"updatedRange\": \"Sheet1!A1:E5\",\n \"updatedRows\": 5,\n \"updatedColumns\": 5,\n \"updatedCells\": 25\n}\n" + } + } + }, + { + "request": { + "method": "GET", + "uri": "https://sheets.googleapis.com/v4/spreadsheets/1OzMP0HH2Jv_kdY815pcsQr8y8XC_W_a08iz-f06-b4A/values/%27Sheet1%27%21A1%3AD4", + "body": null, + "headers": { + "User-Agent": [ + "python-requests/2.31.0" + ], + "Accept-Encoding": [ + "gzip, deflate" + ], + "Accept": [ + "*/*" + ], + "Connection": [ + "keep-alive" + ], + "authorization": [ + "" + ] + } + }, + "response": { + "status": { + "code": 200, + "message": "OK" + }, + "headers": { + "Content-Type": [ + "application/json; charset=UTF-8" + ], + "x-l2-request-path": [ + "l2-managed-6" + ], + "X-Frame-Options": [ + "SAMEORIGIN" + ], + "Server": [ + "ESF" + ], + "Transfer-Encoding": [ + "chunked" + ], + "Date": [ + "Thu, 28 Sep 2023 22:12:05 GMT" + ], + "Alt-Svc": [ + "h3=\":443\"; ma=2592000,h3-29=\":443\"; ma=2592000" + ], + "X-Content-Type-Options": [ + "nosniff" + ], + "X-XSS-Protection": [ + "0" + ], + "Vary": [ + "Origin", + "X-Origin", + "Referer" + ], + "Cache-Control": [ + "private" + ], + "content-length": [ + "178" + ] + }, + "body": { + "string": "{\n \"range\": \"Sheet1!A1:D4\",\n \"majorDimension\": \"ROWS\",\n \"values\": [\n [\n \"1\",\n \"2\"\n ],\n [\n \"3\",\n \"4\"\n ],\n [\n \"5\",\n \"6\"\n ]\n ]\n}\n" + } + } + }, + { + "request": { + "method": "DELETE", + "uri": "https://www.googleapis.com/drive/v3/files/1OzMP0HH2Jv_kdY815pcsQr8y8XC_W_a08iz-f06-b4A?supportsAllDrives=True", + "body": null, + "headers": { + "User-Agent": [ + "python-requests/2.31.0" + ], + "Accept-Encoding": [ + "gzip, deflate" + ], + "Accept": [ + "*/*" + ], + "Connection": [ + "keep-alive" + ], + "Content-Length": [ + "0" + ], + "authorization": [ + "" + ] + } + }, + "response": { + "status": { + "code": 204, + "message": "No Content" + }, + "headers": { + "Content-Type": [ + "text/html" + ], + "X-Frame-Options": [ + "SAMEORIGIN" + ], + "Pragma": [ + "no-cache" + ], + "Server": [ + "ESF" + ], + "Date": [ + "Thu, 28 Sep 2023 22:12:05 GMT" + ], + "Alt-Svc": [ + "h3=\":443\"; ma=2592000,h3-29=\":443\"; ma=2592000" + ], + "Expires": [ + "Mon, 01 Jan 1990 00:00:00 GMT" + ], + "X-Content-Type-Options": [ + "nosniff" + ], + "Content-Length": [ + "0" + ], + "X-XSS-Protection": [ + "0" + ], + "Vary": [ + "Origin, X-Origin" + ], + "Cache-Control": [ + "no-cache, no-store, max-age=0, must-revalidate" + ] + }, + "body": { + "string": "" + } + } + } + ] +} diff --git a/tests/cassettes/WorksheetTest.test_update_acell.json b/tests/cassettes/WorksheetTest.test_update_acell.json index 643474460..748b9bf00 100644 --- a/tests/cassettes/WorksheetTest.test_update_acell.json +++ b/tests/cassettes/WorksheetTest.test_update_acell.json @@ -1154,6 +1154,534 @@ "string": "" } } + }, + { + "request": { + "method": "POST", + "uri": "https://www.googleapis.com/drive/v3/files?supportsAllDrives=True", + "body": "{\"name\": \"Test WorksheetTest test_update_acell\", \"mimeType\": \"application/vnd.google-apps.spreadsheet\"}", + "headers": { + "User-Agent": [ + "python-requests/2.31.0" + ], + "Accept-Encoding": [ + "gzip, deflate" + ], + "Accept": [ + "*/*" + ], + "Connection": [ + "keep-alive" + ], + "Content-Length": [ + "103" + ], + "Content-Type": [ + "application/json" + ], + "authorization": [ + "" + ] + } + }, + "response": { + "status": { + "code": 200, + "message": "OK" + }, + "headers": { + "Expires": [ + "Mon, 01 Jan 1990 00:00:00 GMT" + ], + "Server": [ + "ESF" + ], + "Cache-Control": [ + "no-cache, no-store, max-age=0, must-revalidate" + ], + "Content-Type": [ + "application/json; charset=UTF-8" + ], + "Date": [ + "Thu, 28 Sep 2023 22:04:11 GMT" + ], + "X-Content-Type-Options": [ + "nosniff" + ], + "Pragma": [ + "no-cache" + ], + "Transfer-Encoding": [ + "chunked" + ], + "X-Frame-Options": [ + "SAMEORIGIN" + ], + "Alt-Svc": [ + "h3=\":443\"; ma=2592000,h3-29=\":443\"; ma=2592000" + ], + "Vary": [ + "Origin, X-Origin" + ], + "X-XSS-Protection": [ + "0" + ], + "content-length": [ + "190" + ] + }, + "body": { + "string": "{\n \"kind\": \"drive#file\",\n \"id\": \"1kTy39ZPF4F8obHLb3mLWKeBbdeFNOH6ckIdCASAHfPo\",\n \"name\": \"Test WorksheetTest test_update_acell\",\n \"mimeType\": \"application/vnd.google-apps.spreadsheet\"\n}\n" + } + } + }, + { + "request": { + "method": "GET", + "uri": "https://sheets.googleapis.com/v4/spreadsheets/1kTy39ZPF4F8obHLb3mLWKeBbdeFNOH6ckIdCASAHfPo?includeGridData=false", + "body": null, + "headers": { + "User-Agent": [ + "python-requests/2.31.0" + ], + "Accept-Encoding": [ + "gzip, deflate" + ], + "Accept": [ + "*/*" + ], + "Connection": [ + "keep-alive" + ], + "authorization": [ + "" + ] + } + }, + "response": { + "status": { + "code": 200, + "message": "OK" + }, + "headers": { + "Server": [ + "ESF" + ], + "Content-Type": [ + "application/json; charset=UTF-8" + ], + "Cache-Control": [ + "private" + ], + "Date": [ + "Thu, 28 Sep 2023 22:04:12 GMT" + ], + "X-Content-Type-Options": [ + "nosniff" + ], + "Transfer-Encoding": [ + "chunked" + ], + "x-l2-request-path": [ + "l2-managed-6" + ], + "X-Frame-Options": [ + "SAMEORIGIN" + ], + "Alt-Svc": [ + "h3=\":443\"; ma=2592000,h3-29=\":443\"; ma=2592000" + ], + "Vary": [ + "Origin", + "X-Origin", + "Referer" + ], + "X-XSS-Protection": [ + "0" + ], + "content-length": [ + "3334" + ] + }, + "body": { + "string": "{\n \"spreadsheetId\": \"1kTy39ZPF4F8obHLb3mLWKeBbdeFNOH6ckIdCASAHfPo\",\n \"properties\": {\n \"title\": \"Test WorksheetTest test_update_acell\",\n \"locale\": \"en_US\",\n \"autoRecalc\": \"ON_CHANGE\",\n \"timeZone\": \"Etc/GMT\",\n \"defaultFormat\": {\n \"backgroundColor\": {\n \"red\": 1,\n \"green\": 1,\n \"blue\": 1\n },\n \"padding\": {\n \"top\": 2,\n \"right\": 3,\n \"bottom\": 2,\n \"left\": 3\n },\n \"verticalAlignment\": \"BOTTOM\",\n \"wrapStrategy\": \"OVERFLOW_CELL\",\n \"textFormat\": {\n \"foregroundColor\": {},\n \"fontFamily\": \"arial,sans,sans-serif\",\n \"fontSize\": 10,\n \"bold\": false,\n \"italic\": false,\n \"strikethrough\": false,\n \"underline\": false,\n \"foregroundColorStyle\": {\n \"rgbColor\": {}\n }\n },\n \"backgroundColorStyle\": {\n \"rgbColor\": {\n \"red\": 1,\n \"green\": 1,\n \"blue\": 1\n }\n }\n },\n \"spreadsheetTheme\": {\n \"primaryFontFamily\": \"Arial\",\n \"themeColors\": [\n {\n \"colorType\": \"TEXT\",\n \"color\": {\n \"rgbColor\": {}\n }\n },\n {\n \"colorType\": \"BACKGROUND\",\n \"color\": {\n \"rgbColor\": {\n \"red\": 1,\n \"green\": 1,\n \"blue\": 1\n }\n }\n },\n {\n \"colorType\": \"ACCENT1\",\n \"color\": {\n \"rgbColor\": {\n \"red\": 0.25882354,\n \"green\": 0.52156866,\n \"blue\": 0.95686275\n }\n }\n },\n {\n \"colorType\": \"ACCENT2\",\n \"color\": {\n \"rgbColor\": {\n \"red\": 0.91764706,\n \"green\": 0.2627451,\n \"blue\": 0.20784314\n }\n }\n },\n {\n \"colorType\": \"ACCENT3\",\n \"color\": {\n \"rgbColor\": {\n \"red\": 0.9843137,\n \"green\": 0.7372549,\n \"blue\": 0.015686275\n }\n }\n },\n {\n \"colorType\": \"ACCENT4\",\n \"color\": {\n \"rgbColor\": {\n \"red\": 0.20392157,\n \"green\": 0.65882355,\n \"blue\": 0.3254902\n }\n }\n },\n {\n \"colorType\": \"ACCENT5\",\n \"color\": {\n \"rgbColor\": {\n \"red\": 1,\n \"green\": 0.42745098,\n \"blue\": 0.003921569\n }\n }\n },\n {\n \"colorType\": \"ACCENT6\",\n \"color\": {\n \"rgbColor\": {\n \"red\": 0.27450982,\n \"green\": 0.7411765,\n \"blue\": 0.7764706\n }\n }\n },\n {\n \"colorType\": \"LINK\",\n \"color\": {\n \"rgbColor\": {\n \"red\": 0.06666667,\n \"green\": 0.33333334,\n \"blue\": 0.8\n }\n }\n }\n ]\n }\n },\n \"sheets\": [\n {\n \"properties\": {\n \"sheetId\": 0,\n \"title\": \"Sheet1\",\n \"index\": 0,\n \"sheetType\": \"GRID\",\n \"gridProperties\": {\n \"rowCount\": 1000,\n \"columnCount\": 26\n }\n }\n }\n ],\n \"spreadsheetUrl\": \"https://docs.google.com/spreadsheets/d/1kTy39ZPF4F8obHLb3mLWKeBbdeFNOH6ckIdCASAHfPo/edit\"\n}\n" + } + } + }, + { + "request": { + "method": "GET", + "uri": "https://sheets.googleapis.com/v4/spreadsheets/1kTy39ZPF4F8obHLb3mLWKeBbdeFNOH6ckIdCASAHfPo?includeGridData=false", + "body": null, + "headers": { + "User-Agent": [ + "python-requests/2.31.0" + ], + "Accept-Encoding": [ + "gzip, deflate" + ], + "Accept": [ + "*/*" + ], + "Connection": [ + "keep-alive" + ], + "authorization": [ + "" + ] + } + }, + "response": { + "status": { + "code": 200, + "message": "OK" + }, + "headers": { + "Server": [ + "ESF" + ], + "Content-Type": [ + "application/json; charset=UTF-8" + ], + "Cache-Control": [ + "private" + ], + "Date": [ + "Thu, 28 Sep 2023 22:04:12 GMT" + ], + "X-Content-Type-Options": [ + "nosniff" + ], + "Transfer-Encoding": [ + "chunked" + ], + "x-l2-request-path": [ + "l2-managed-6" + ], + "X-Frame-Options": [ + "SAMEORIGIN" + ], + "Alt-Svc": [ + "h3=\":443\"; ma=2592000,h3-29=\":443\"; ma=2592000" + ], + "Vary": [ + "Origin", + "X-Origin", + "Referer" + ], + "X-XSS-Protection": [ + "0" + ], + "content-length": [ + "3334" + ] + }, + "body": { + "string": "{\n \"spreadsheetId\": \"1kTy39ZPF4F8obHLb3mLWKeBbdeFNOH6ckIdCASAHfPo\",\n \"properties\": {\n \"title\": \"Test WorksheetTest test_update_acell\",\n \"locale\": \"en_US\",\n \"autoRecalc\": \"ON_CHANGE\",\n \"timeZone\": \"Etc/GMT\",\n \"defaultFormat\": {\n \"backgroundColor\": {\n \"red\": 1,\n \"green\": 1,\n \"blue\": 1\n },\n \"padding\": {\n \"top\": 2,\n \"right\": 3,\n \"bottom\": 2,\n \"left\": 3\n },\n \"verticalAlignment\": \"BOTTOM\",\n \"wrapStrategy\": \"OVERFLOW_CELL\",\n \"textFormat\": {\n \"foregroundColor\": {},\n \"fontFamily\": \"arial,sans,sans-serif\",\n \"fontSize\": 10,\n \"bold\": false,\n \"italic\": false,\n \"strikethrough\": false,\n \"underline\": false,\n \"foregroundColorStyle\": {\n \"rgbColor\": {}\n }\n },\n \"backgroundColorStyle\": {\n \"rgbColor\": {\n \"red\": 1,\n \"green\": 1,\n \"blue\": 1\n }\n }\n },\n \"spreadsheetTheme\": {\n \"primaryFontFamily\": \"Arial\",\n \"themeColors\": [\n {\n \"colorType\": \"TEXT\",\n \"color\": {\n \"rgbColor\": {}\n }\n },\n {\n \"colorType\": \"BACKGROUND\",\n \"color\": {\n \"rgbColor\": {\n \"red\": 1,\n \"green\": 1,\n \"blue\": 1\n }\n }\n },\n {\n \"colorType\": \"ACCENT1\",\n \"color\": {\n \"rgbColor\": {\n \"red\": 0.25882354,\n \"green\": 0.52156866,\n \"blue\": 0.95686275\n }\n }\n },\n {\n \"colorType\": \"ACCENT2\",\n \"color\": {\n \"rgbColor\": {\n \"red\": 0.91764706,\n \"green\": 0.2627451,\n \"blue\": 0.20784314\n }\n }\n },\n {\n \"colorType\": \"ACCENT3\",\n \"color\": {\n \"rgbColor\": {\n \"red\": 0.9843137,\n \"green\": 0.7372549,\n \"blue\": 0.015686275\n }\n }\n },\n {\n \"colorType\": \"ACCENT4\",\n \"color\": {\n \"rgbColor\": {\n \"red\": 0.20392157,\n \"green\": 0.65882355,\n \"blue\": 0.3254902\n }\n }\n },\n {\n \"colorType\": \"ACCENT5\",\n \"color\": {\n \"rgbColor\": {\n \"red\": 1,\n \"green\": 0.42745098,\n \"blue\": 0.003921569\n }\n }\n },\n {\n \"colorType\": \"ACCENT6\",\n \"color\": {\n \"rgbColor\": {\n \"red\": 0.27450982,\n \"green\": 0.7411765,\n \"blue\": 0.7764706\n }\n }\n },\n {\n \"colorType\": \"LINK\",\n \"color\": {\n \"rgbColor\": {\n \"red\": 0.06666667,\n \"green\": 0.33333334,\n \"blue\": 0.8\n }\n }\n }\n ]\n }\n },\n \"sheets\": [\n {\n \"properties\": {\n \"sheetId\": 0,\n \"title\": \"Sheet1\",\n \"index\": 0,\n \"sheetType\": \"GRID\",\n \"gridProperties\": {\n \"rowCount\": 1000,\n \"columnCount\": 26\n }\n }\n }\n ],\n \"spreadsheetUrl\": \"https://docs.google.com/spreadsheets/d/1kTy39ZPF4F8obHLb3mLWKeBbdeFNOH6ckIdCASAHfPo/edit\"\n}\n" + } + } + }, + { + "request": { + "method": "POST", + "uri": "https://sheets.googleapis.com/v4/spreadsheets/1kTy39ZPF4F8obHLb3mLWKeBbdeFNOH6ckIdCASAHfPo/values/%27Sheet1%27:clear", + "body": null, + "headers": { + "User-Agent": [ + "python-requests/2.31.0" + ], + "Accept-Encoding": [ + "gzip, deflate" + ], + "Accept": [ + "*/*" + ], + "Connection": [ + "keep-alive" + ], + "Content-Length": [ + "0" + ], + "authorization": [ + "" + ] + } + }, + "response": { + "status": { + "code": 200, + "message": "OK" + }, + "headers": { + "Server": [ + "ESF" + ], + "Content-Type": [ + "application/json; charset=UTF-8" + ], + "Cache-Control": [ + "private" + ], + "Date": [ + "Thu, 28 Sep 2023 22:04:13 GMT" + ], + "X-Content-Type-Options": [ + "nosniff" + ], + "Transfer-Encoding": [ + "chunked" + ], + "x-l2-request-path": [ + "l2-managed-6" + ], + "X-Frame-Options": [ + "SAMEORIGIN" + ], + "Alt-Svc": [ + "h3=\":443\"; ma=2592000,h3-29=\":443\"; ma=2592000" + ], + "Vary": [ + "Origin", + "X-Origin", + "Referer" + ], + "X-XSS-Protection": [ + "0" + ], + "content-length": [ + "107" + ] + }, + "body": { + "string": "{\n \"spreadsheetId\": \"1kTy39ZPF4F8obHLb3mLWKeBbdeFNOH6ckIdCASAHfPo\",\n \"clearedRange\": \"Sheet1!A1:Z1000\"\n}\n" + } + } + }, + { + "request": { + "method": "PUT", + "uri": "https://sheets.googleapis.com/v4/spreadsheets/1kTy39ZPF4F8obHLb3mLWKeBbdeFNOH6ckIdCASAHfPo/values/%27Sheet1%27%21A2?valueInputOption=USER_ENTERED", + "body": "{\"values\": [[\"test_update_acell 1\"]]}", + "headers": { + "User-Agent": [ + "python-requests/2.31.0" + ], + "Accept-Encoding": [ + "gzip, deflate" + ], + "Accept": [ + "*/*" + ], + "Connection": [ + "keep-alive" + ], + "Content-Length": [ + "37" + ], + "Content-Type": [ + "application/json" + ], + "authorization": [ + "" + ] + } + }, + "response": { + "status": { + "code": 200, + "message": "OK" + }, + "headers": { + "Server": [ + "ESF" + ], + "Content-Type": [ + "application/json; charset=UTF-8" + ], + "Cache-Control": [ + "private" + ], + "Date": [ + "Thu, 28 Sep 2023 22:04:13 GMT" + ], + "X-Content-Type-Options": [ + "nosniff" + ], + "Transfer-Encoding": [ + "chunked" + ], + "x-l2-request-path": [ + "l2-managed-6" + ], + "X-Frame-Options": [ + "SAMEORIGIN" + ], + "Alt-Svc": [ + "h3=\":443\"; ma=2592000,h3-29=\":443\"; ma=2592000" + ], + "Vary": [ + "Origin", + "X-Origin", + "Referer" + ], + "X-XSS-Protection": [ + "0" + ], + "content-length": [ + "165" + ] + }, + "body": { + "string": "{\n \"spreadsheetId\": \"1kTy39ZPF4F8obHLb3mLWKeBbdeFNOH6ckIdCASAHfPo\",\n \"updatedRange\": \"Sheet1!A2\",\n \"updatedRows\": 1,\n \"updatedColumns\": 1,\n \"updatedCells\": 1\n}\n" + } + } + }, + { + "request": { + "method": "GET", + "uri": "https://sheets.googleapis.com/v4/spreadsheets/1kTy39ZPF4F8obHLb3mLWKeBbdeFNOH6ckIdCASAHfPo/values/%27Sheet1%27%21A2?valueRenderOption=FORMATTED_VALUE", + "body": null, + "headers": { + "User-Agent": [ + "python-requests/2.31.0" + ], + "Accept-Encoding": [ + "gzip, deflate" + ], + "Accept": [ + "*/*" + ], + "Connection": [ + "keep-alive" + ], + "authorization": [ + "" + ] + } + }, + "response": { + "status": { + "code": 200, + "message": "OK" + }, + "headers": { + "Server": [ + "ESF" + ], + "Content-Type": [ + "application/json; charset=UTF-8" + ], + "Cache-Control": [ + "private" + ], + "Date": [ + "Thu, 28 Sep 2023 22:04:13 GMT" + ], + "X-Content-Type-Options": [ + "nosniff" + ], + "Transfer-Encoding": [ + "chunked" + ], + "x-l2-request-path": [ + "l2-managed-6" + ], + "X-Frame-Options": [ + "SAMEORIGIN" + ], + "Alt-Svc": [ + "h3=\":443\"; ma=2592000,h3-29=\":443\"; ma=2592000" + ], + "Vary": [ + "Origin", + "X-Origin", + "Referer" + ], + "X-XSS-Protection": [ + "0" + ], + "content-length": [ + "114" + ] + }, + "body": { + "string": "{\n \"range\": \"Sheet1!A2\",\n \"majorDimension\": \"ROWS\",\n \"values\": [\n [\n \"test_update_acell 1\"\n ]\n ]\n}\n" + } + } + }, + { + "request": { + "method": "DELETE", + "uri": "https://www.googleapis.com/drive/v3/files/1kTy39ZPF4F8obHLb3mLWKeBbdeFNOH6ckIdCASAHfPo?supportsAllDrives=True", + "body": null, + "headers": { + "User-Agent": [ + "python-requests/2.31.0" + ], + "Accept-Encoding": [ + "gzip, deflate" + ], + "Accept": [ + "*/*" + ], + "Connection": [ + "keep-alive" + ], + "Content-Length": [ + "0" + ], + "authorization": [ + "" + ] + } + }, + "response": { + "status": { + "code": 204, + "message": "No Content" + }, + "headers": { + "Expires": [ + "Mon, 01 Jan 1990 00:00:00 GMT" + ], + "Server": [ + "ESF" + ], + "Cache-Control": [ + "no-cache, no-store, max-age=0, must-revalidate" + ], + "Content-Type": [ + "text/html" + ], + "Date": [ + "Thu, 28 Sep 2023 22:04:14 GMT" + ], + "X-Content-Type-Options": [ + "nosniff" + ], + "Content-Length": [ + "0" + ], + "Pragma": [ + "no-cache" + ], + "X-Frame-Options": [ + "SAMEORIGIN" + ], + "Alt-Svc": [ + "h3=\":443\"; ma=2592000,h3-29=\":443\"; ma=2592000" + ], + "Vary": [ + "Origin, X-Origin" + ], + "X-XSS-Protection": [ + "0" + ] + }, + "body": { + "string": "" + } + } } ] } diff --git a/tests/worksheet_test.py b/tests/worksheet_test.py index f13c7c4ae..fc8f15722 100644 --- a/tests/worksheet_test.py +++ b/tests/worksheet_test.py @@ -147,6 +147,31 @@ def test_get_values_merge_cells_outside_of_range(self): ) self.assertEqual(values_with_merged, expected_values) + @pytest.mark.vcr() + def test_get_values_and_maintain_size(self): + """test get_values with maintain_size=True""" + self.sheet.resize(5, 5) + sheet_data = [ + ["1", "2", "", "", ""], + ["3", "4", "", "", ""], + ["5", "6", "", "", ""], + ["", "", "", "", ""], + ["", "", "", "", ""], + ] + request_range = "A1:D4" + expected_values = [ + ["1", "2", "", ""], + ["3", "4", "", ""], + ["5", "6", "", ""], + ["", "", "", ""], + ] + + self.sheet.update("A1:E5", sheet_data) + + values = self.sheet.get_values(request_range, maintain_size=True) + + self.assertEqual(values, expected_values) + @pytest.mark.vcr() def test_update_acell(self): sg = self._sequence_generator() From 566602dfcb240d704e38cb5772ec96310bdab77b Mon Sep 17 00:00:00 2001 From: alifeee Date: Tue, 17 Oct 2023 16:23:36 +0100 Subject: [PATCH 6/9] implement "is not None" for return statement --- gspread/utils.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/gspread/utils.py b/gspread/utils.py index 5805ea99d..859809030 100644 --- a/gspread/utils.py +++ b/gspread/utils.py @@ -887,9 +887,7 @@ def is_full_a1_notation(range_name: str) -> bool: >>> is_full_a1_notation("A1:B") False """ - if A1_ADDR_FULL_RE.search(range_name): - return True - return False + return A1_ADDR_FULL_RE.search(range_name) is not None def get_a1_from_absolute_range(range_name: str) -> str: From 07aab27de6761ddc26705040a9d374b9a7eafcaa Mon Sep 17 00:00:00 2001 From: alifeee Date: Tue, 17 Oct 2023 16:29:22 +0100 Subject: [PATCH 7/9] remove partial indexes to grid_range... and add clarifying comment --- gspread/worksheet.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/gspread/worksheet.py b/gspread/worksheet.py index aed601c97..ed7248bb2 100644 --- a/gspread/worksheet.py +++ b/gspread/worksheet.py @@ -991,15 +991,13 @@ def get(self, range_name=None, **kwargs): values = response.get("values", []) + # range_name must be a full grid range so that we can guarantee + # startRowIndex and endRowIndex properties if kwargs["maintain_size"] is True and is_full_a1_notation(range_name): a1_range = get_a1_from_absolute_range(range_name) grid_range = a1_range_to_grid_range(a1_range) - rows = grid_range.get("endRowIndex", self.row_count) - grid_range.get( - "startRowIndex", 0 - ) - cols = grid_range.get("endColumnIndex", self.col_count) - grid_range.get( - "startColumnIndex", 0 - ) + rows = grid_range["endRowIndex"] - grid_range["startRowIndex"] + cols = grid_range["endColumnIndex"] - grid_range["startColumnIndex"] values = fill_gaps(values, rows=rows, cols=cols) response["values"] = values From 2c1b554739b930fe1fd84256c1f12420646b02a4 Mon Sep 17 00:00:00 2001 From: alifeee Date: Thu, 19 Oct 2023 10:29:15 +0100 Subject: [PATCH 8/9] change lambda function to dict (cherry picked from commit 4de778e6fea17ecfe30b16ae637a73c7cc7d0bfc) --- gspread/utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gspread/utils.py b/gspread/utils.py index 859809030..7555e2211 100644 --- a/gspread/utils.py +++ b/gspread/utils.py @@ -583,7 +583,7 @@ def cell_list_to_rect(cell_list): if not cell_list: return [] - rows = defaultdict(lambda: {}) + rows = defaultdict(dict) row_offset = min(c.row for c in cell_list) col_offset = min(c.col for c in cell_list) From baf8a8ae60621bf246ba1788ea8e464d30ee0d10 Mon Sep 17 00:00:00 2001 From: Alexandre Lavigne Date: Sat, 21 Oct 2023 18:01:33 +0200 Subject: [PATCH 9/9] add new argument documentation Signed-off-by: Alexandre Lavigne --- README.md | 16 ++++++++++++++++ gspread/worksheet.py | 39 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 55 insertions(+) diff --git a/README.md b/README.md index 94ef8db36..2f4c6674a 100644 --- a/README.md +++ b/README.md @@ -135,6 +135,22 @@ values_list = worksheet.col_values(1) list_of_lists = worksheet.get_values() ``` +### Getting a range of values + +Receive only the cells with a value in them +```python +>>> worksheet.get_values("A1:B4") +[['A1', 'B1'], ['A2']] +``` + +Receive a lists of lists matching the requested size +regardless if values are empty or not + +```python +>>> worksheet.get_values("A1:B4", maintain_size=True) +[['A1', 'B1'], ['A2', ''], ['', ''], ['', '']] +``` + ### Finding a Cell ```python diff --git a/gspread/worksheet.py b/gspread/worksheet.py index ed7248bb2..6fcf4a4c4 100644 --- a/gspread/worksheet.py +++ b/gspread/worksheet.py @@ -446,6 +446,25 @@ def get_values(self, range_name=None, combine_merged_cells=False, **kwargs): Empty trailing rows and columns will not be included. + :param bool maintain_size: (optional) Returns a matrix of values matching the size of the requested range. + + .. warning:: + + This can only work if the requested range is a complete bounded A1 notation. + Example: ``A1:D4``: OK, ``C3:F``: Not OK, we don't know the end size of the requested range. + + This does not work with ``named_range`` either. + + Examples:: + + # Works + >>> worksheet.get("A1:B2", maintain_size=True) + [['A1', 'B1'], ['A2', '']] + + # Does NOT maintain the requested size + >>> worksheet.get("A1:B", maintain_size=True) + [['A1', 'B1'], ['A2'], [], ['A4', 'B4'], ['A5']] + Examples:: # Return all values from the sheet @@ -957,6 +976,26 @@ def get(self, range_name=None, **kwargs): This is ignored if ``value_render_option`` is ``ValueRenderOption.formatted``. The default ``date_time_render_option`` is ``DateTimeOption.serial_number``. + + :param bool maintain_size: (optional) Returns a matrix of values matching the size of the requested range. + + .. warning:: + + This can only work if the requested range is a complete bounded A1 notation. + Example: ``A1:D4``: OK, ``C3:F``: Not OK, we don't know the end size of the requested range. + + This does not work with ``named_range`` either. + + Examples:: + + # Works + >>> worksheet.get("A1:B2", maintain_size=True) + [['A1', 'B1'], ['A2', '']] + + # Does NOT maintain the requested size + >>> worksheet.get("A1:B", maintain_size=True) + [['A1', 'B1'], ['A2'], [], ['A4', 'B4'], ['A5']] + :type date_time_render_option: :namedtuple:`~gspread.utils.DateTimeOption` :rtype: :class:`gspread.worksheet.ValueRange`