universal-mcp-applications 0.1.19__py3-none-any.whl → 0.1.21__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of universal-mcp-applications might be problematic. Click here for more details.
- universal_mcp/applications/fireflies/app.py +109 -1
- universal_mcp/applications/google_drive/README.md +1 -1
- universal_mcp/applications/google_drive/app.py +22 -10
- universal_mcp/applications/google_sheet/app.py +130 -130
- universal_mcp/applications/scraper/app.py +219 -0
- universal_mcp/applications/unipile/app.py +257 -0
- universal_mcp/applications/yahoo_finance/README.md +17 -0
- universal_mcp/applications/yahoo_finance/__init__.py +1 -0
- universal_mcp/applications/yahoo_finance/app.py +258 -0
- universal_mcp/applications/youtube/app.py +16 -6
- {universal_mcp_applications-0.1.19.dist-info → universal_mcp_applications-0.1.21.dist-info}/METADATA +2 -1
- {universal_mcp_applications-0.1.19.dist-info → universal_mcp_applications-0.1.21.dist-info}/RECORD +14 -14
- universal_mcp/applications/replicate/README.md +0 -18
- universal_mcp/applications/replicate/__init__.py +0 -1
- universal_mcp/applications/replicate/app.py +0 -493
- {universal_mcp_applications-0.1.19.dist-info → universal_mcp_applications-0.1.21.dist-info}/WHEEL +0 -0
- {universal_mcp_applications-0.1.19.dist-info → universal_mcp_applications-0.1.21.dist-info}/licenses/LICENSE +0 -0
|
@@ -41,25 +41,25 @@ class GoogleSheetApp(APIApplication):
|
|
|
41
41
|
response = self._post(url, data=spreadsheet_data)
|
|
42
42
|
return self._handle_response(response)
|
|
43
43
|
|
|
44
|
-
def get_spreadsheet_metadata(self,
|
|
44
|
+
def get_spreadsheet_metadata(self, spreadsheetId: str) -> dict[str, Any]:
|
|
45
45
|
"""
|
|
46
46
|
Retrieves a spreadsheet's metadata and structural properties, such as sheet names, IDs, and named ranges, using its unique ID. This function intentionally excludes cell data, distinguishing it from `get_values` which fetches the actual content within cells.
|
|
47
47
|
|
|
48
48
|
Args:
|
|
49
|
-
|
|
49
|
+
spreadsheetId: The unique identifier of the Google Spreadsheet to retrieve (found in the spreadsheet's URL)
|
|
50
50
|
|
|
51
51
|
Returns:
|
|
52
52
|
A dictionary containing the full spreadsheet metadata and contents, including properties, sheets, named ranges, and other spreadsheet-specific information from the Google Sheets API
|
|
53
53
|
|
|
54
54
|
Raises:
|
|
55
|
-
HTTPError: When the API request fails due to invalid
|
|
55
|
+
HTTPError: When the API request fails due to invalid spreadsheetId or insufficient permissions
|
|
56
56
|
ConnectionError: When there's a network connectivity issue
|
|
57
57
|
ValueError: When the response cannot be parsed as JSON
|
|
58
58
|
|
|
59
59
|
Tags:
|
|
60
60
|
get, retrieve, spreadsheet, api, metadata, read, important
|
|
61
61
|
"""
|
|
62
|
-
url = f"{self.base_url}/{
|
|
62
|
+
url = f"{self.base_url}/{spreadsheetId}"
|
|
63
63
|
response = self._get(url)
|
|
64
64
|
return self._handle_response(response)
|
|
65
65
|
|
|
@@ -85,8 +85,8 @@ class GoogleSheetApp(APIApplication):
|
|
|
85
85
|
A dictionary containing the API response with the requested spreadsheet values and metadata
|
|
86
86
|
|
|
87
87
|
Raises:
|
|
88
|
-
HTTPError: If the API request fails due to invalid
|
|
89
|
-
ValueError: If the
|
|
88
|
+
HTTPError: If the API request fails due to invalid spreadsheetId, insufficient permissions, or invalid range format
|
|
89
|
+
ValueError: If the spreadsheetId is empty or invalid
|
|
90
90
|
|
|
91
91
|
Tags:
|
|
92
92
|
get, read, spreadsheet, values, important
|
|
@@ -105,26 +105,26 @@ class GoogleSheetApp(APIApplication):
|
|
|
105
105
|
return self._handle_response(response)
|
|
106
106
|
|
|
107
107
|
def batch_get_values_by_range(
|
|
108
|
-
self,
|
|
108
|
+
self, spreadsheetId: str, ranges: list[str] | None = None
|
|
109
109
|
) -> dict[str, Any]:
|
|
110
110
|
"""
|
|
111
111
|
Efficiently retrieves values from multiple predefined A1 notation ranges in a single API request. Unlike `get_values`, which fetches a single range, or `batch_get_values_by_data_filter`, which uses dynamic filtering criteria, this function operates on a simple list of range strings for bulk data retrieval.
|
|
112
112
|
|
|
113
113
|
Args:
|
|
114
|
-
|
|
114
|
+
spreadsheetId: The unique identifier of the Google Spreadsheet to retrieve values from
|
|
115
115
|
ranges: Optional list of A1 notation or R1C1 notation range strings (e.g., ['Sheet1!A1:B2', 'Sheet2!C3:D4']). If None, returns values from the entire spreadsheet
|
|
116
116
|
|
|
117
117
|
Returns:
|
|
118
118
|
A dictionary containing the API response with the requested spreadsheet values and metadata
|
|
119
119
|
|
|
120
120
|
Raises:
|
|
121
|
-
HTTPError: If the API request fails due to invalid
|
|
122
|
-
ValueError: If the
|
|
121
|
+
HTTPError: If the API request fails due to invalid spreadsheetId, insufficient permissions, or invalid range format
|
|
122
|
+
ValueError: If the spreadsheetId is empty or invalid
|
|
123
123
|
|
|
124
124
|
Tags:
|
|
125
125
|
get, batch, read, spreadsheet, values
|
|
126
126
|
"""
|
|
127
|
-
url = f"{self.base_url}/{
|
|
127
|
+
url = f"{self.base_url}/{spreadsheetId}/values:batchGet"
|
|
128
128
|
params = {}
|
|
129
129
|
if ranges:
|
|
130
130
|
params["ranges"] = ranges
|
|
@@ -133,7 +133,7 @@ class GoogleSheetApp(APIApplication):
|
|
|
133
133
|
|
|
134
134
|
def insert_dimensions(
|
|
135
135
|
self,
|
|
136
|
-
|
|
136
|
+
spreadsheetId: str,
|
|
137
137
|
sheet_id: int,
|
|
138
138
|
dimension: str,
|
|
139
139
|
start_index: int,
|
|
@@ -150,7 +150,7 @@ class GoogleSheetApp(APIApplication):
|
|
|
150
150
|
Use this when you need to add rows/columns in the middle of your data.
|
|
151
151
|
|
|
152
152
|
Args:
|
|
153
|
-
|
|
153
|
+
spreadsheetId: The ID of the spreadsheet to update. Example: "abc123spreadsheetId"
|
|
154
154
|
sheet_id: The ID of the sheet where the dimensions will be inserted. Example: 0
|
|
155
155
|
dimension: The dimension to insert. Valid values are "ROWS" or "COLUMNS". Example: "ROWS"
|
|
156
156
|
start_index: The start index (0-based) of the dimension range to insert. The inserted dimensions will be placed before this index. Example: 1
|
|
@@ -165,13 +165,13 @@ class GoogleSheetApp(APIApplication):
|
|
|
165
165
|
|
|
166
166
|
Raises:
|
|
167
167
|
HTTPError: When the API request fails due to invalid parameters or insufficient permissions
|
|
168
|
-
ValueError: When
|
|
168
|
+
ValueError: When spreadsheetId is empty or dimension is not "ROWS" or "COLUMNS"
|
|
169
169
|
|
|
170
170
|
Tags:
|
|
171
171
|
insert, modify, spreadsheet, rows, columns, dimensions, important
|
|
172
172
|
"""
|
|
173
|
-
if not
|
|
174
|
-
raise ValueError("
|
|
173
|
+
if not spreadsheetId:
|
|
174
|
+
raise ValueError("spreadsheetId cannot be empty")
|
|
175
175
|
|
|
176
176
|
if dimension not in ["ROWS", "COLUMNS"]:
|
|
177
177
|
raise ValueError('dimension must be either "ROWS" or "COLUMNS"')
|
|
@@ -182,7 +182,7 @@ class GoogleSheetApp(APIApplication):
|
|
|
182
182
|
if start_index >= end_index:
|
|
183
183
|
raise ValueError("end_index must be greater than start_index")
|
|
184
184
|
|
|
185
|
-
url = f"{self.base_url}/{
|
|
185
|
+
url = f"{self.base_url}/{spreadsheetId}:batchUpdate"
|
|
186
186
|
|
|
187
187
|
request_body: dict[str, Any] = {
|
|
188
188
|
"requests": [
|
|
@@ -217,7 +217,7 @@ class GoogleSheetApp(APIApplication):
|
|
|
217
217
|
|
|
218
218
|
def append_dimensions(
|
|
219
219
|
self,
|
|
220
|
-
|
|
220
|
+
spreadsheetId: str,
|
|
221
221
|
sheet_id: int,
|
|
222
222
|
dimension: str,
|
|
223
223
|
length: int,
|
|
@@ -229,7 +229,7 @@ class GoogleSheetApp(APIApplication):
|
|
|
229
229
|
Use this when you need to extend the sheet with additional space at the bottom or right.
|
|
230
230
|
|
|
231
231
|
Args:
|
|
232
|
-
|
|
232
|
+
spreadsheetId: The unique identifier of the Google Spreadsheet to modify
|
|
233
233
|
sheet_id: The ID of the sheet within the spreadsheet (0 for first sheet)
|
|
234
234
|
dimension: The type of dimension to append - "ROWS" or "COLUMNS"
|
|
235
235
|
length: The number of rows or columns to append to the end
|
|
@@ -239,13 +239,13 @@ class GoogleSheetApp(APIApplication):
|
|
|
239
239
|
|
|
240
240
|
Raises:
|
|
241
241
|
HTTPError: When the API request fails due to invalid parameters or insufficient permissions
|
|
242
|
-
ValueError: When
|
|
242
|
+
ValueError: When spreadsheetId is empty, dimension is not "ROWS" or "COLUMNS", or length is not positive
|
|
243
243
|
|
|
244
244
|
Tags:
|
|
245
245
|
append, modify, spreadsheet, rows, columns, dimensions, important
|
|
246
246
|
"""
|
|
247
|
-
if not
|
|
248
|
-
raise ValueError("
|
|
247
|
+
if not spreadsheetId:
|
|
248
|
+
raise ValueError("spreadsheetId cannot be empty")
|
|
249
249
|
|
|
250
250
|
if dimension not in ["ROWS", "COLUMNS"]:
|
|
251
251
|
raise ValueError('dimension must be either "ROWS" or "COLUMNS"')
|
|
@@ -253,7 +253,7 @@ class GoogleSheetApp(APIApplication):
|
|
|
253
253
|
if length <= 0:
|
|
254
254
|
raise ValueError("length must be a positive integer")
|
|
255
255
|
|
|
256
|
-
url = f"{self.base_url}/{
|
|
256
|
+
url = f"{self.base_url}/{spreadsheetId}:batchUpdate"
|
|
257
257
|
|
|
258
258
|
request_body = {
|
|
259
259
|
"requests": [
|
|
@@ -272,7 +272,7 @@ class GoogleSheetApp(APIApplication):
|
|
|
272
272
|
|
|
273
273
|
def delete_dimensions(
|
|
274
274
|
self,
|
|
275
|
-
|
|
275
|
+
spreadsheetId: str,
|
|
276
276
|
sheet_id: int,
|
|
277
277
|
dimension: str,
|
|
278
278
|
start_index: int,
|
|
@@ -285,7 +285,7 @@ class GoogleSheetApp(APIApplication):
|
|
|
285
285
|
Deletes a specified range of rows or columns, permanently removing them and shifting subsequent cells. This alters the sheet's structure, unlike `clear_values` which only removes cell content. It is the direct counterpart to `insert_dimensions`, which adds space within the data grid.
|
|
286
286
|
|
|
287
287
|
Args:
|
|
288
|
-
|
|
288
|
+
spreadsheetId: The ID of the spreadsheet. Example: "abc123xyz789"
|
|
289
289
|
sheet_id: The ID of the sheet from which to delete the dimension. Example: 0 for first sheet
|
|
290
290
|
dimension: The dimension to delete. Example: "ROWS"
|
|
291
291
|
start_index: The zero-based start index of the range to delete, inclusive. The start index must be less than the end index. Example: 0
|
|
@@ -299,13 +299,13 @@ class GoogleSheetApp(APIApplication):
|
|
|
299
299
|
|
|
300
300
|
Raises:
|
|
301
301
|
HTTPError: When the API request fails due to invalid parameters or insufficient permissions
|
|
302
|
-
ValueError: When
|
|
302
|
+
ValueError: When spreadsheetId is empty, dimension is not "ROWS" or "COLUMNS", or indices are invalid
|
|
303
303
|
|
|
304
304
|
Tags:
|
|
305
305
|
delete, modify, spreadsheet, rows, columns, dimensions, important
|
|
306
306
|
"""
|
|
307
|
-
if not
|
|
308
|
-
raise ValueError("
|
|
307
|
+
if not spreadsheetId:
|
|
308
|
+
raise ValueError("spreadsheetId cannot be empty")
|
|
309
309
|
|
|
310
310
|
if dimension not in ["ROWS", "COLUMNS"]:
|
|
311
311
|
raise ValueError('dimension must be either "ROWS" or "COLUMNS"')
|
|
@@ -316,7 +316,7 @@ class GoogleSheetApp(APIApplication):
|
|
|
316
316
|
if start_index >= end_index:
|
|
317
317
|
raise ValueError("end_index must be greater than start_index")
|
|
318
318
|
|
|
319
|
-
url = f"{self.base_url}/{
|
|
319
|
+
url = f"{self.base_url}/{spreadsheetId}:batchUpdate"
|
|
320
320
|
|
|
321
321
|
request_body: dict[str, Any] = {
|
|
322
322
|
"requests": [
|
|
@@ -397,7 +397,7 @@ class GoogleSheetApp(APIApplication):
|
|
|
397
397
|
|
|
398
398
|
Raises:
|
|
399
399
|
HTTPError: When the API request fails due to invalid parameters or insufficient permissions
|
|
400
|
-
ValueError: When
|
|
400
|
+
ValueError: When spreadsheetId is empty or invalid parameters are provided
|
|
401
401
|
|
|
402
402
|
Tags:
|
|
403
403
|
add, sheet, spreadsheet, create
|
|
@@ -479,7 +479,7 @@ class GoogleSheetApp(APIApplication):
|
|
|
479
479
|
|
|
480
480
|
def add_basic_chart(
|
|
481
481
|
self,
|
|
482
|
-
|
|
482
|
+
spreadsheetId: str,
|
|
483
483
|
source_sheet_id: int,
|
|
484
484
|
chart_title: str,
|
|
485
485
|
chart_type: str,
|
|
@@ -497,7 +497,7 @@ class GoogleSheetApp(APIApplication):
|
|
|
497
497
|
Use this when you need to visualize data in different chart formats.
|
|
498
498
|
|
|
499
499
|
Args:
|
|
500
|
-
|
|
500
|
+
spreadsheetId: The unique identifier of the Google Spreadsheet to modify
|
|
501
501
|
source_sheet_id: The ID of the sheet containing the source data
|
|
502
502
|
chart_title: The title for the chart
|
|
503
503
|
chart_type: The type of chart to create. Supported types: "COLUMN", "BAR", "LINE", "AREA", "STEPPED_AREA", "SCATTER", "COMBO"
|
|
@@ -513,18 +513,18 @@ class GoogleSheetApp(APIApplication):
|
|
|
513
513
|
|
|
514
514
|
Raises:
|
|
515
515
|
HTTPError: When the API request fails due to invalid parameters or insufficient permissions
|
|
516
|
-
ValueError: When
|
|
516
|
+
ValueError: When spreadsheetId is empty or invalid parameters are provided
|
|
517
517
|
|
|
518
518
|
Tags:
|
|
519
519
|
add, chart, basic-chart, visualization
|
|
520
520
|
"""
|
|
521
|
-
if not
|
|
522
|
-
raise ValueError("
|
|
521
|
+
if not spreadsheetId:
|
|
522
|
+
raise ValueError("spreadsheetId cannot be empty")
|
|
523
523
|
|
|
524
524
|
if not chart_title:
|
|
525
525
|
raise ValueError("chart_title cannot be empty")
|
|
526
526
|
|
|
527
|
-
url = f"{self.base_url}/{
|
|
527
|
+
url = f"{self.base_url}/{spreadsheetId}:batchUpdate"
|
|
528
528
|
|
|
529
529
|
# Build the chart specification
|
|
530
530
|
chart_spec = {
|
|
@@ -628,7 +628,7 @@ class GoogleSheetApp(APIApplication):
|
|
|
628
628
|
|
|
629
629
|
def add_pie_chart(
|
|
630
630
|
self,
|
|
631
|
-
|
|
631
|
+
spreadsheetId: str,
|
|
632
632
|
source_sheet_id: int,
|
|
633
633
|
chart_title: str,
|
|
634
634
|
data_range: dict,
|
|
@@ -644,7 +644,7 @@ class GoogleSheetApp(APIApplication):
|
|
|
644
644
|
Use this when you need to visualize data as proportions of a whole.
|
|
645
645
|
|
|
646
646
|
Args:
|
|
647
|
-
|
|
647
|
+
spreadsheetId: The unique identifier of the Google Spreadsheet to modify
|
|
648
648
|
source_sheet_id: The ID of the sheet containing the source data
|
|
649
649
|
chart_title: The title for the chart
|
|
650
650
|
data_range: Dictionary containing data range info (e.g., {"startRowIndex": 0, "endRowIndex": 7, "startColumnIndex": 0, "endColumnIndex": 2})
|
|
@@ -658,13 +658,13 @@ class GoogleSheetApp(APIApplication):
|
|
|
658
658
|
|
|
659
659
|
Raises:
|
|
660
660
|
HTTPError: When the API request fails due to invalid parameters or insufficient permissions
|
|
661
|
-
ValueError: When
|
|
661
|
+
ValueError: When spreadsheetId is empty or invalid parameters are provided
|
|
662
662
|
|
|
663
663
|
Tags:
|
|
664
664
|
add, chart, pie, visualization
|
|
665
665
|
"""
|
|
666
|
-
if not
|
|
667
|
-
raise ValueError("
|
|
666
|
+
if not spreadsheetId:
|
|
667
|
+
raise ValueError("spreadsheetId cannot be empty")
|
|
668
668
|
|
|
669
669
|
if not chart_title:
|
|
670
670
|
raise ValueError("chart_title cannot be empty")
|
|
@@ -672,7 +672,7 @@ class GoogleSheetApp(APIApplication):
|
|
|
672
672
|
if pie_hole is not None and not 0 <= pie_hole <= 1:
|
|
673
673
|
raise ValueError("pie_hole must be between 0.0 and 1.0")
|
|
674
674
|
|
|
675
|
-
url = f"{self.base_url}/{
|
|
675
|
+
url = f"{self.base_url}/{spreadsheetId}:batchUpdate"
|
|
676
676
|
|
|
677
677
|
# Build the pie chart specification
|
|
678
678
|
pie_chart_spec = {
|
|
@@ -747,7 +747,7 @@ class GoogleSheetApp(APIApplication):
|
|
|
747
747
|
|
|
748
748
|
def add_table(
|
|
749
749
|
self,
|
|
750
|
-
|
|
750
|
+
spreadsheetId: str,
|
|
751
751
|
sheet_id: int,
|
|
752
752
|
table_name: str,
|
|
753
753
|
table_id: str,
|
|
@@ -764,7 +764,7 @@ class GoogleSheetApp(APIApplication):
|
|
|
764
764
|
Use this when you need to create structured data with headers, footers, and column types.
|
|
765
765
|
|
|
766
766
|
Args:
|
|
767
|
-
|
|
767
|
+
spreadsheetId: The unique identifier of the Google Spreadsheet to modify
|
|
768
768
|
sheet_id: The ID of the sheet where the table will be created
|
|
769
769
|
table_name: The name of the table
|
|
770
770
|
table_id: The unique identifier for the table
|
|
@@ -778,13 +778,13 @@ class GoogleSheetApp(APIApplication):
|
|
|
778
778
|
|
|
779
779
|
Raises:
|
|
780
780
|
HTTPError: When the API request fails due to invalid parameters or insufficient permissions
|
|
781
|
-
ValueError: When
|
|
781
|
+
ValueError: When spreadsheetId is empty or invalid parameters are provided
|
|
782
782
|
|
|
783
783
|
Tags:
|
|
784
784
|
add, table, structured-data
|
|
785
785
|
"""
|
|
786
|
-
if not
|
|
787
|
-
raise ValueError("
|
|
786
|
+
if not spreadsheetId:
|
|
787
|
+
raise ValueError("spreadsheetId cannot be empty")
|
|
788
788
|
|
|
789
789
|
if not table_name:
|
|
790
790
|
raise ValueError("table_name cannot be empty")
|
|
@@ -827,7 +827,7 @@ class GoogleSheetApp(APIApplication):
|
|
|
827
827
|
f"Invalid column type '{prop['columnType']}' at index {i}. Valid types are: {', '.join(valid_column_types)}"
|
|
828
828
|
)
|
|
829
829
|
|
|
830
|
-
url = f"{self.base_url}/{
|
|
830
|
+
url = f"{self.base_url}/{spreadsheetId}:batchUpdate"
|
|
831
831
|
|
|
832
832
|
# Build the table specification
|
|
833
833
|
table_spec = {
|
|
@@ -854,7 +854,7 @@ class GoogleSheetApp(APIApplication):
|
|
|
854
854
|
|
|
855
855
|
def update_table(
|
|
856
856
|
self,
|
|
857
|
-
|
|
857
|
+
spreadsheetId: str,
|
|
858
858
|
table_id: str,
|
|
859
859
|
table_name: str | None = None,
|
|
860
860
|
start_row_index: int | None = None,
|
|
@@ -870,7 +870,7 @@ class GoogleSheetApp(APIApplication):
|
|
|
870
870
|
Use this when you need to modify an existing table's structure or properties.
|
|
871
871
|
|
|
872
872
|
Args:
|
|
873
|
-
|
|
873
|
+
spreadsheetId: The unique identifier of the Google Spreadsheet to modify
|
|
874
874
|
table_id: The unique identifier of the table to update
|
|
875
875
|
table_name: Optional new name for the table
|
|
876
876
|
start_row_index: Optional new starting row index (0-based)
|
|
@@ -884,13 +884,13 @@ class GoogleSheetApp(APIApplication):
|
|
|
884
884
|
|
|
885
885
|
Raises:
|
|
886
886
|
HTTPError: When the API request fails due to invalid parameters or insufficient permissions
|
|
887
|
-
ValueError: When
|
|
887
|
+
ValueError: When spreadsheetId or table_id is empty or invalid parameters are provided
|
|
888
888
|
|
|
889
889
|
Tags:
|
|
890
890
|
update, table, modify, structured-data
|
|
891
891
|
"""
|
|
892
|
-
if not
|
|
893
|
-
raise ValueError("
|
|
892
|
+
if not spreadsheetId:
|
|
893
|
+
raise ValueError("spreadsheetId cannot be empty")
|
|
894
894
|
|
|
895
895
|
if not table_id:
|
|
896
896
|
raise ValueError("table_id cannot be empty")
|
|
@@ -943,7 +943,7 @@ class GoogleSheetApp(APIApplication):
|
|
|
943
943
|
f"Invalid column type '{prop['columnType']}' at index {i}. Valid types are: {', '.join(valid_column_types)}"
|
|
944
944
|
)
|
|
945
945
|
|
|
946
|
-
url = f"{self.base_url}/{
|
|
946
|
+
url = f"{self.base_url}/{spreadsheetId}:batchUpdate"
|
|
947
947
|
|
|
948
948
|
# Build the table specification and track fields to update
|
|
949
949
|
table_spec: dict[str, Any] = {"tableId": table_id}
|
|
@@ -995,31 +995,31 @@ class GoogleSheetApp(APIApplication):
|
|
|
995
995
|
response = self._post(url, data=request_body)
|
|
996
996
|
return self._handle_response(response)
|
|
997
997
|
|
|
998
|
-
def clear_values(self,
|
|
998
|
+
def clear_values(self, spreadsheetId: str, range: str) -> dict[str, Any]:
|
|
999
999
|
"""
|
|
1000
1000
|
Clears data from a single, specified cell range while preserving all formatting. Unlike `delete_dimensions`, it only removes content, not the cells themselves. For clearing multiple ranges simultaneously, use the `batch_clear_values` function.
|
|
1001
1001
|
|
|
1002
1002
|
Args:
|
|
1003
|
-
|
|
1003
|
+
spreadsheetId: The unique identifier of the Google Spreadsheet to modify
|
|
1004
1004
|
range: The A1 or R1C1 notation range of cells to clear (e.g., 'Sheet1!A1:B2')
|
|
1005
1005
|
|
|
1006
1006
|
Returns:
|
|
1007
1007
|
A dictionary containing the Google Sheets API response
|
|
1008
1008
|
|
|
1009
1009
|
Raises:
|
|
1010
|
-
HttpError: When the API request fails due to invalid
|
|
1011
|
-
ValueError: When
|
|
1010
|
+
HttpError: When the API request fails due to invalid spreadsheetId, invalid range format, or insufficient permissions
|
|
1011
|
+
ValueError: When spreadsheetId is empty or range is in invalid format
|
|
1012
1012
|
|
|
1013
1013
|
Tags:
|
|
1014
1014
|
clear, modify, spreadsheet, api, sheets, data-management, important
|
|
1015
1015
|
"""
|
|
1016
|
-
url = f"{self.base_url}/{
|
|
1016
|
+
url = f"{self.base_url}/{spreadsheetId}/values/{range}:clear"
|
|
1017
1017
|
response = self._post(url, data={})
|
|
1018
1018
|
return self._handle_response(response)
|
|
1019
1019
|
|
|
1020
1020
|
def update_values(
|
|
1021
1021
|
self,
|
|
1022
|
-
|
|
1022
|
+
spreadsheetId: str,
|
|
1023
1023
|
range: str,
|
|
1024
1024
|
values: list[list[Any]],
|
|
1025
1025
|
value_input_option: str = "RAW",
|
|
@@ -1028,7 +1028,7 @@ class GoogleSheetApp(APIApplication):
|
|
|
1028
1028
|
Overwrites cell values within a specific A1 notation range using a provided 2D list. This function replaces existing data in a predefined area, distinguishing it from `append_values`, which adds new rows after a table instead of overwriting a specific block of cells.
|
|
1029
1029
|
|
|
1030
1030
|
Args:
|
|
1031
|
-
|
|
1031
|
+
spreadsheetId: The unique identifier of the target Google Spreadsheet
|
|
1032
1032
|
range: The A1 notation range where values will be updated (e.g., 'Sheet1!A1:B2')
|
|
1033
1033
|
values: A list of lists containing the data to write, where each inner list represents a row of values
|
|
1034
1034
|
value_input_option: Determines how input data should be interpreted: 'RAW' (as-is) or 'USER_ENTERED' (parsed as UI input). Defaults to 'RAW'
|
|
@@ -1043,7 +1043,7 @@ class GoogleSheetApp(APIApplication):
|
|
|
1043
1043
|
Tags:
|
|
1044
1044
|
update, write, sheets, api, important, data-modification, google-sheets
|
|
1045
1045
|
"""
|
|
1046
|
-
url = f"{self.base_url}/{
|
|
1046
|
+
url = f"{self.base_url}/{spreadsheetId}/values/{range}"
|
|
1047
1047
|
params = {"valueInputOption": value_input_option}
|
|
1048
1048
|
data = {"range": range, "values": values}
|
|
1049
1049
|
response = self._put(url, data=data, params=params)
|
|
@@ -1051,14 +1051,14 @@ class GoogleSheetApp(APIApplication):
|
|
|
1051
1051
|
|
|
1052
1052
|
def batch_clear_values(
|
|
1053
1053
|
self,
|
|
1054
|
-
|
|
1054
|
+
spreadsheetId: str,
|
|
1055
1055
|
ranges: list[str],
|
|
1056
1056
|
) -> dict[str, Any]:
|
|
1057
1057
|
"""
|
|
1058
1058
|
Clears cell values from multiple specified ranges in a single batch operation, preserving existing formatting. Unlike `clear_values`, which handles a single range, this method efficiently processes a list of ranges at once, removing only the content and not the cells themselves.
|
|
1059
1059
|
|
|
1060
1060
|
Args:
|
|
1061
|
-
|
|
1061
|
+
spreadsheetId: The ID of the spreadsheet to update. Example: "1q2w3e4r5t6y7u8i9o0p"
|
|
1062
1062
|
ranges: The ranges to clear, in A1 notation or R1C1 notation. Example: ["Sheet1!A1:B2", "Sheet1!C3:D4"]
|
|
1063
1063
|
|
|
1064
1064
|
Returns:
|
|
@@ -1066,18 +1066,18 @@ class GoogleSheetApp(APIApplication):
|
|
|
1066
1066
|
|
|
1067
1067
|
Raises:
|
|
1068
1068
|
HTTPError: When the API request fails due to invalid parameters or insufficient permissions
|
|
1069
|
-
ValueError: When
|
|
1069
|
+
ValueError: When spreadsheetId is empty or ranges is empty
|
|
1070
1070
|
|
|
1071
1071
|
Tags:
|
|
1072
1072
|
clear, batch, values, spreadsheet
|
|
1073
1073
|
"""
|
|
1074
|
-
if not
|
|
1075
|
-
raise ValueError("
|
|
1074
|
+
if not spreadsheetId:
|
|
1075
|
+
raise ValueError("spreadsheetId cannot be empty")
|
|
1076
1076
|
|
|
1077
1077
|
if not ranges or not isinstance(ranges, list) or len(ranges) == 0:
|
|
1078
1078
|
raise ValueError("ranges must be a non-empty list")
|
|
1079
1079
|
|
|
1080
|
-
url = f"{self.base_url}/{
|
|
1080
|
+
url = f"{self.base_url}/{spreadsheetId}/values:batchClear"
|
|
1081
1081
|
|
|
1082
1082
|
request_body = {"ranges": ranges}
|
|
1083
1083
|
|
|
@@ -1086,7 +1086,7 @@ class GoogleSheetApp(APIApplication):
|
|
|
1086
1086
|
|
|
1087
1087
|
def batch_get_values_by_data_filter(
|
|
1088
1088
|
self,
|
|
1089
|
-
|
|
1089
|
+
spreadsheetId: str,
|
|
1090
1090
|
data_filters: list[dict],
|
|
1091
1091
|
major_dimension: str | None = None,
|
|
1092
1092
|
value_render_option: str | None = None,
|
|
@@ -1096,7 +1096,7 @@ class GoogleSheetApp(APIApplication):
|
|
|
1096
1096
|
Retrieves values from spreadsheet ranges matching a list of data filters. This method provides dynamic, criteria-based selection using A1 notation or grid coordinates, unlike `batch_get_values_by_range` which uses a simple list of range strings. It is ideal for fetching multiple, specific datasets in one request.
|
|
1097
1097
|
|
|
1098
1098
|
Args:
|
|
1099
|
-
|
|
1099
|
+
spreadsheetId: The ID of the spreadsheet to retrieve data from. Example: "1q2w3e4r5t6y7u8i9o0p"
|
|
1100
1100
|
data_filters: The data filters used to match the ranges of values to retrieve. Ranges that match any of the specified data filters are included in the response. Each filter can contain:
|
|
1101
1101
|
- a1Range: Selects data that matches the specified A1 range. Example: "Sheet1!A1:B5"
|
|
1102
1102
|
- gridRange: Selects data that matches the specified grid range. Example: {"sheetId": 0, "startRowIndex": 0, "endRowIndex": 5, "startColumnIndex": 0, "endColumnIndex": 2}
|
|
@@ -1109,13 +1109,13 @@ class GoogleSheetApp(APIApplication):
|
|
|
1109
1109
|
|
|
1110
1110
|
Raises:
|
|
1111
1111
|
HTTPError: When the API request fails due to invalid parameters or insufficient permissions
|
|
1112
|
-
ValueError: When
|
|
1112
|
+
ValueError: When spreadsheetId is empty or data_filters is empty
|
|
1113
1113
|
|
|
1114
1114
|
Tags:
|
|
1115
1115
|
get, batch, data-filter, values, spreadsheet
|
|
1116
1116
|
"""
|
|
1117
|
-
if not
|
|
1118
|
-
raise ValueError("
|
|
1117
|
+
if not spreadsheetId:
|
|
1118
|
+
raise ValueError("spreadsheetId cannot be empty")
|
|
1119
1119
|
|
|
1120
1120
|
if (
|
|
1121
1121
|
not data_filters
|
|
@@ -1144,7 +1144,7 @@ class GoogleSheetApp(APIApplication):
|
|
|
1144
1144
|
'date_time_render_option must be either "SERIAL_NUMBER" or "FORMATTED_STRING"'
|
|
1145
1145
|
)
|
|
1146
1146
|
|
|
1147
|
-
url = f"{self.base_url}/{
|
|
1147
|
+
url = f"{self.base_url}/{spreadsheetId}/values:batchGetByDataFilter"
|
|
1148
1148
|
|
|
1149
1149
|
request_body: dict[str, Any] = {"dataFilters": data_filters}
|
|
1150
1150
|
|
|
@@ -1163,18 +1163,18 @@ class GoogleSheetApp(APIApplication):
|
|
|
1163
1163
|
|
|
1164
1164
|
def copy_sheet_to_spreadsheet(
|
|
1165
1165
|
self,
|
|
1166
|
-
|
|
1166
|
+
spreadsheetId: str,
|
|
1167
1167
|
sheet_id: int,
|
|
1168
|
-
|
|
1168
|
+
destination_spreadsheetId: str,
|
|
1169
1169
|
) -> dict[str, Any]:
|
|
1170
1170
|
"""
|
|
1171
1171
|
Copies a specific sheet, including all its data and formatting, from a source spreadsheet to a different destination spreadsheet. This action duplicates an entire worksheet into another workbook, returning properties of the newly created sheet.
|
|
1172
1172
|
|
|
1173
1173
|
|
|
1174
1174
|
Args:
|
|
1175
|
-
|
|
1175
|
+
spreadsheetId: The ID of the spreadsheet containing the sheet to copy. Example: "1qZ_..."
|
|
1176
1176
|
sheet_id: The ID of the sheet to copy. Example: 0
|
|
1177
|
-
|
|
1177
|
+
destination_spreadsheetId: The ID of the spreadsheet to copy the sheet to. Example: "2rY_..."
|
|
1178
1178
|
|
|
1179
1179
|
Returns:
|
|
1180
1180
|
A dictionary containing the Google Sheets API response with copy details
|
|
@@ -1186,25 +1186,25 @@ class GoogleSheetApp(APIApplication):
|
|
|
1186
1186
|
Tags:
|
|
1187
1187
|
copy, sheet, spreadsheet, duplicate
|
|
1188
1188
|
"""
|
|
1189
|
-
if not
|
|
1190
|
-
raise ValueError("
|
|
1189
|
+
if not spreadsheetId:
|
|
1190
|
+
raise ValueError("spreadsheetId cannot be empty")
|
|
1191
1191
|
|
|
1192
1192
|
if sheet_id is None:
|
|
1193
1193
|
raise ValueError("sheet_id cannot be empty")
|
|
1194
1194
|
|
|
1195
|
-
if not
|
|
1196
|
-
raise ValueError("
|
|
1195
|
+
if not destination_spreadsheetId:
|
|
1196
|
+
raise ValueError("destination_spreadsheetId cannot be empty")
|
|
1197
1197
|
|
|
1198
|
-
url = f"{self.base_url}/{
|
|
1198
|
+
url = f"{self.base_url}/{spreadsheetId}/sheets/{sheet_id}:copyTo"
|
|
1199
1199
|
|
|
1200
|
-
request_body = {"destinationSpreadsheetId":
|
|
1200
|
+
request_body = {"destinationSpreadsheetId": destination_spreadsheetId}
|
|
1201
1201
|
|
|
1202
1202
|
response = self._post(url, data=request_body)
|
|
1203
1203
|
return self._handle_response(response)
|
|
1204
1204
|
|
|
1205
1205
|
def write_values_to_sheet(
|
|
1206
1206
|
self,
|
|
1207
|
-
|
|
1207
|
+
spreadsheetId: str,
|
|
1208
1208
|
sheet_name: str,
|
|
1209
1209
|
values: list[list[Any]],
|
|
1210
1210
|
first_cell_location: str | None = None,
|
|
@@ -1215,7 +1215,7 @@ class GoogleSheetApp(APIApplication):
|
|
|
1215
1215
|
Writes a 2D list of values to a sheet, overwriting existing data. Data is written starting from a specified cell, or defaults to cell A1 if no location is provided. This differs from `append_values`, which adds new rows after existing data without replacing content.
|
|
1216
1216
|
|
|
1217
1217
|
Args:
|
|
1218
|
-
|
|
1218
|
+
spreadsheetId: The unique identifier of the Google Sheets spreadsheet to be updated. Example: "1BxiMVs0XRA5nFMdKvBdBZjgmUUqptlbs74OgvE2upms"
|
|
1219
1219
|
sheet_name: The name of the specific sheet within the spreadsheet to update. Example: "Sheet1"
|
|
1220
1220
|
values: A 2D list of cell values. Each inner list represents a row. Values can be strings, numbers, or booleans. Ensure columns are properly aligned across rows. Example: [['Item', 'Cost', 'Stocked', 'Ship Date'], ['Wheel', 20.5, True, '2020-06-01'], ['Screw', 0.5, True, '2020-06-03'], ['Nut', 0.25, False, '2020-06-02']]
|
|
1221
1221
|
first_cell_location: The starting cell for the update range, specified in A1 notation (e.g., 'A1', 'B2'). The update will extend from this cell to the right and down, based on the provided values. If omitted, values are appended to the end of the sheet. Example: "A1"
|
|
@@ -1227,13 +1227,13 @@ class GoogleSheetApp(APIApplication):
|
|
|
1227
1227
|
|
|
1228
1228
|
Raises:
|
|
1229
1229
|
HTTPError: When the API request fails due to invalid parameters or insufficient permissions
|
|
1230
|
-
ValueError: When
|
|
1230
|
+
ValueError: When spreadsheetId is empty, sheet_name is empty, or values is empty
|
|
1231
1231
|
|
|
1232
1232
|
Tags:
|
|
1233
1233
|
batch, update, write, sheets, api, important, data-modification, google-sheets
|
|
1234
1234
|
"""
|
|
1235
|
-
if not
|
|
1236
|
-
raise ValueError("
|
|
1235
|
+
if not spreadsheetId:
|
|
1236
|
+
raise ValueError("spreadsheetId cannot be empty")
|
|
1237
1237
|
|
|
1238
1238
|
if not sheet_name:
|
|
1239
1239
|
raise ValueError("sheet_name cannot be empty")
|
|
@@ -1254,7 +1254,7 @@ class GoogleSheetApp(APIApplication):
|
|
|
1254
1254
|
# Append to the sheet (no specific range)
|
|
1255
1255
|
range_str = f"{sheet_name}"
|
|
1256
1256
|
|
|
1257
|
-
url = f"{self.base_url}/{
|
|
1257
|
+
url = f"{self.base_url}/{spreadsheetId}/values/{range_str}"
|
|
1258
1258
|
|
|
1259
1259
|
params = {
|
|
1260
1260
|
"valueInputOption": value_input_option,
|
|
@@ -1268,7 +1268,7 @@ class GoogleSheetApp(APIApplication):
|
|
|
1268
1268
|
|
|
1269
1269
|
def append_values(
|
|
1270
1270
|
self,
|
|
1271
|
-
|
|
1271
|
+
spreadsheetId: str,
|
|
1272
1272
|
range: str,
|
|
1273
1273
|
value_input_option: str,
|
|
1274
1274
|
values: list[list[Any]],
|
|
@@ -1281,7 +1281,7 @@ class GoogleSheetApp(APIApplication):
|
|
|
1281
1281
|
Appends rows of data after a specified table in a Google Sheet. Distinct from `update_values` which overwrites data, this function adds new rows at the end of the table. It can also insert rows, shifting existing cells down, offering finer control over data addition.
|
|
1282
1282
|
|
|
1283
1283
|
Args:
|
|
1284
|
-
|
|
1284
|
+
spreadsheetId: The ID of the spreadsheet to update. Example: "1q0gLhLdGXYZblahblahblah"
|
|
1285
1285
|
range: The A1 notation of a range to search for a logical table of data. Values are appended after the last row of the table. Example: "Sheet1!A1:B2"
|
|
1286
1286
|
value_input_option: How the input data should be interpreted. Required. Options: "RAW" or "USER_ENTERED". Example: "USER_ENTERED"
|
|
1287
1287
|
values: The data to be written. This is an array of arrays, the outer array representing all the data and each inner array representing a major dimension. Each item in the inner array corresponds with one cell. Example: [["A1_val1", "A1_val2"], ["A2_val1", "A2_val2"]]
|
|
@@ -1300,8 +1300,8 @@ class GoogleSheetApp(APIApplication):
|
|
|
1300
1300
|
Tags:
|
|
1301
1301
|
append, values, spreadsheet, data, important
|
|
1302
1302
|
"""
|
|
1303
|
-
if not
|
|
1304
|
-
raise ValueError("
|
|
1303
|
+
if not spreadsheetId:
|
|
1304
|
+
raise ValueError("spreadsheetId cannot be empty")
|
|
1305
1305
|
|
|
1306
1306
|
if not range:
|
|
1307
1307
|
raise ValueError("range cannot be empty")
|
|
@@ -1343,7 +1343,7 @@ class GoogleSheetApp(APIApplication):
|
|
|
1343
1343
|
'response_date_time_render_option must be either "SERIAL_NUMBER" or "FORMATTED_STRING"'
|
|
1344
1344
|
)
|
|
1345
1345
|
|
|
1346
|
-
url = f"{self.base_url}/{
|
|
1346
|
+
url = f"{self.base_url}/{spreadsheetId}/values/{range}:append"
|
|
1347
1347
|
|
|
1348
1348
|
params: dict[str, Any] = {"valueInputOption": value_input_option}
|
|
1349
1349
|
|
|
@@ -1367,14 +1367,14 @@ class GoogleSheetApp(APIApplication):
|
|
|
1367
1367
|
|
|
1368
1368
|
def clear_basic_filter(
|
|
1369
1369
|
self,
|
|
1370
|
-
|
|
1370
|
+
spreadsheetId: str,
|
|
1371
1371
|
sheet_id: int,
|
|
1372
1372
|
) -> dict[str, Any]:
|
|
1373
1373
|
"""
|
|
1374
1374
|
Removes the basic filter from a specified sheet, clearing active sorting and filtering criteria to restore the default data view. As the direct counterpart to `set_basic_filter`, this function removes the entire filter object, not just the cell content.
|
|
1375
1375
|
|
|
1376
1376
|
Args:
|
|
1377
|
-
|
|
1377
|
+
spreadsheetId: The ID of the spreadsheet. Example: "abc123xyz789"
|
|
1378
1378
|
sheet_id: The ID of the sheet on which the basic filter should be cleared. Example: 0
|
|
1379
1379
|
|
|
1380
1380
|
Returns:
|
|
@@ -1382,18 +1382,18 @@ class GoogleSheetApp(APIApplication):
|
|
|
1382
1382
|
|
|
1383
1383
|
Raises:
|
|
1384
1384
|
HTTPError: When the API request fails due to invalid parameters or insufficient permissions
|
|
1385
|
-
ValueError: When
|
|
1385
|
+
ValueError: When spreadsheetId is empty or sheet_id is negative
|
|
1386
1386
|
|
|
1387
1387
|
Tags:
|
|
1388
1388
|
clear, filter, basic-filter, spreadsheet
|
|
1389
1389
|
"""
|
|
1390
|
-
if not
|
|
1391
|
-
raise ValueError("
|
|
1390
|
+
if not spreadsheetId:
|
|
1391
|
+
raise ValueError("spreadsheetId cannot be empty")
|
|
1392
1392
|
|
|
1393
1393
|
if sheet_id < 0:
|
|
1394
1394
|
raise ValueError("sheet_id must be non-negative")
|
|
1395
1395
|
|
|
1396
|
-
url = f"{self.base_url}/{
|
|
1396
|
+
url = f"{self.base_url}/{spreadsheetId}:batchUpdate"
|
|
1397
1397
|
|
|
1398
1398
|
request_body = {"requests": [{"clearBasicFilter": {"sheetId": sheet_id}}]}
|
|
1399
1399
|
|
|
@@ -1402,14 +1402,14 @@ class GoogleSheetApp(APIApplication):
|
|
|
1402
1402
|
|
|
1403
1403
|
def delete_sheet(
|
|
1404
1404
|
self,
|
|
1405
|
-
|
|
1405
|
+
spreadsheetId: str,
|
|
1406
1406
|
sheet_id: int,
|
|
1407
1407
|
) -> dict[str, Any]:
|
|
1408
1408
|
"""
|
|
1409
1409
|
Permanently deletes a specific sheet (worksheet) from a Google Spreadsheet using its sheet ID. This operation removes the target sheet and all its contents, acting as the direct counterpart to the `add_sheet` function which creates new sheets within a spreadsheet.
|
|
1410
1410
|
|
|
1411
1411
|
Args:
|
|
1412
|
-
|
|
1412
|
+
spreadsheetId: The ID of the spreadsheet from which to delete the sheet. Example: "abc123xyz789"
|
|
1413
1413
|
sheet_id: The ID of the sheet to delete. If the sheet is of DATA_SOURCE type, the associated DataSource is also deleted. Example: 123456789
|
|
1414
1414
|
|
|
1415
1415
|
Returns:
|
|
@@ -1417,18 +1417,18 @@ class GoogleSheetApp(APIApplication):
|
|
|
1417
1417
|
|
|
1418
1418
|
Raises:
|
|
1419
1419
|
HTTPError: When the API request fails due to invalid parameters or insufficient permissions
|
|
1420
|
-
ValueError: When
|
|
1420
|
+
ValueError: When spreadsheetId is empty or sheet_id is negative
|
|
1421
1421
|
|
|
1422
1422
|
Tags:
|
|
1423
1423
|
delete, sheet, spreadsheet, worksheet
|
|
1424
1424
|
"""
|
|
1425
|
-
if not
|
|
1426
|
-
raise ValueError("
|
|
1425
|
+
if not spreadsheetId:
|
|
1426
|
+
raise ValueError("spreadsheetId cannot be empty")
|
|
1427
1427
|
|
|
1428
1428
|
if sheet_id < 0:
|
|
1429
1429
|
raise ValueError("sheet_id must be non-negative")
|
|
1430
1430
|
|
|
1431
|
-
url = f"{self.base_url}/{
|
|
1431
|
+
url = f"{self.base_url}/{spreadsheetId}:batchUpdate"
|
|
1432
1432
|
|
|
1433
1433
|
request_body = {"requests": [{"deleteSheet": {"sheetId": sheet_id}}]}
|
|
1434
1434
|
|
|
@@ -1437,7 +1437,7 @@ class GoogleSheetApp(APIApplication):
|
|
|
1437
1437
|
|
|
1438
1438
|
def discover_tables(
|
|
1439
1439
|
self,
|
|
1440
|
-
|
|
1440
|
+
spreadsheetId: str,
|
|
1441
1441
|
min_rows: int = 2,
|
|
1442
1442
|
min_columns: int = 1,
|
|
1443
1443
|
min_confidence: float = 0.5,
|
|
@@ -1446,7 +1446,7 @@ class GoogleSheetApp(APIApplication):
|
|
|
1446
1446
|
Heuristically analyzes a spreadsheet to discover and list all table-like data structures, identifying headers and data boundaries. It returns informal data blocks meeting specified size criteria, distinguishing it from functions like `add_table` that manage formally defined tables.
|
|
1447
1447
|
|
|
1448
1448
|
Args:
|
|
1449
|
-
|
|
1449
|
+
spreadsheetId: Google Sheets ID from the URL (e.g., '1BxiMVs0XRA5nFMdKvBdBZjgmUUqptlbs74OgvE2upms'). Example: "1BxiMVs0XRA5nFMdKvBdBZjgmUUqptlbs74OgvE2upms"
|
|
1450
1450
|
min_rows: Minimum number of data rows to consider a valid table. Example: 2
|
|
1451
1451
|
min_columns: Minimum number of columns to consider a valid table. Example: 1
|
|
1452
1452
|
min_confidence: Minimum confidence score (0.0-1.0) to consider a valid table. Example: 0.5
|
|
@@ -1456,13 +1456,13 @@ class GoogleSheetApp(APIApplication):
|
|
|
1456
1456
|
|
|
1457
1457
|
Raises:
|
|
1458
1458
|
HTTPError: When the API request fails due to invalid parameters or insufficient permissions
|
|
1459
|
-
ValueError: When
|
|
1459
|
+
ValueError: When spreadsheetId is empty or parameters are invalid
|
|
1460
1460
|
|
|
1461
1461
|
Tags:
|
|
1462
1462
|
list, tables, discover, analyze, spreadsheet, important
|
|
1463
1463
|
"""
|
|
1464
|
-
if not
|
|
1465
|
-
raise ValueError("
|
|
1464
|
+
if not spreadsheetId:
|
|
1465
|
+
raise ValueError("spreadsheetId cannot be empty")
|
|
1466
1466
|
|
|
1467
1467
|
if min_rows < 1:
|
|
1468
1468
|
raise ValueError("min_rows must be at least 1")
|
|
@@ -1474,7 +1474,7 @@ class GoogleSheetApp(APIApplication):
|
|
|
1474
1474
|
raise ValueError("min_confidence must be between 0.0 and 1.0")
|
|
1475
1475
|
|
|
1476
1476
|
# Get spreadsheet structure
|
|
1477
|
-
spreadsheet = self.get_spreadsheet_metadata(
|
|
1477
|
+
spreadsheet = self.get_spreadsheet_metadata(spreadsheetId)
|
|
1478
1478
|
|
|
1479
1479
|
tables = []
|
|
1480
1480
|
|
|
@@ -1486,7 +1486,7 @@ class GoogleSheetApp(APIApplication):
|
|
|
1486
1486
|
# Analyze sheet for tables using helper function
|
|
1487
1487
|
sheet_tables = analyze_sheet_for_tables(
|
|
1488
1488
|
self.get_values, # Pass the get_values method as a function
|
|
1489
|
-
|
|
1489
|
+
spreadsheetId,
|
|
1490
1490
|
sheet_id,
|
|
1491
1491
|
sheet_title,
|
|
1492
1492
|
min_rows,
|
|
@@ -1497,7 +1497,7 @@ class GoogleSheetApp(APIApplication):
|
|
|
1497
1497
|
tables.extend(sheet_tables)
|
|
1498
1498
|
|
|
1499
1499
|
return {
|
|
1500
|
-
"
|
|
1500
|
+
"spreadsheetId": spreadsheetId,
|
|
1501
1501
|
"total_tables": len(tables),
|
|
1502
1502
|
"tables": tables,
|
|
1503
1503
|
"analysis_parameters": {
|
|
@@ -1508,7 +1508,7 @@ class GoogleSheetApp(APIApplication):
|
|
|
1508
1508
|
|
|
1509
1509
|
def analyze_table_schema(
|
|
1510
1510
|
self,
|
|
1511
|
-
|
|
1511
|
+
spreadsheetId: str,
|
|
1512
1512
|
table_name: str,
|
|
1513
1513
|
sheet_name: str | None = None,
|
|
1514
1514
|
sample_size: int = 50,
|
|
@@ -1517,7 +1517,7 @@ class GoogleSheetApp(APIApplication):
|
|
|
1517
1517
|
Infers a specified table's schema by analyzing a data sample. After locating the table by name (a value discovered via `discover_tables`), this function determines the most likely data type and properties for each column, providing a detailed structural breakdown of its content.
|
|
1518
1518
|
|
|
1519
1519
|
Args:
|
|
1520
|
-
|
|
1520
|
+
spreadsheetId: Google Sheets ID from the URL (e.g., '1BxiMVs0XRA5nFMdKvBdBZjgmUUqptlbs74OgvE2upms')
|
|
1521
1521
|
table_name: Specific table name from LIST_TABLES response (e.g., 'Sales_Data', 'Employee_List'). Use 'auto' to analyze the largest/most prominent table
|
|
1522
1522
|
sheet_name: Sheet/tab name if table_name is ambiguous across multiple sheets
|
|
1523
1523
|
sample_size: Number of rows to sample for type inference (1-1000, default 50)
|
|
@@ -1527,13 +1527,13 @@ class GoogleSheetApp(APIApplication):
|
|
|
1527
1527
|
|
|
1528
1528
|
Raises:
|
|
1529
1529
|
HTTPError: When the API request fails due to invalid parameters or insufficient permissions
|
|
1530
|
-
ValueError: When
|
|
1530
|
+
ValueError: When spreadsheetId is empty, table_name is empty, or sample_size is invalid
|
|
1531
1531
|
|
|
1532
1532
|
Tags:
|
|
1533
1533
|
schema, analyze, table, structure, types, columns
|
|
1534
1534
|
"""
|
|
1535
|
-
if not
|
|
1536
|
-
raise ValueError("
|
|
1535
|
+
if not spreadsheetId:
|
|
1536
|
+
raise ValueError("spreadsheetId cannot be empty")
|
|
1537
1537
|
|
|
1538
1538
|
if not table_name:
|
|
1539
1539
|
raise ValueError("table_name cannot be empty")
|
|
@@ -1542,7 +1542,7 @@ class GoogleSheetApp(APIApplication):
|
|
|
1542
1542
|
raise ValueError("sample_size must be between 1 and 1000")
|
|
1543
1543
|
|
|
1544
1544
|
# Get spreadsheet structure
|
|
1545
|
-
spreadsheet = self.get_spreadsheet_metadata(
|
|
1545
|
+
spreadsheet = self.get_spreadsheet_metadata(spreadsheetId)
|
|
1546
1546
|
|
|
1547
1547
|
# Find the target table
|
|
1548
1548
|
target_table = None
|
|
@@ -1558,7 +1558,7 @@ class GoogleSheetApp(APIApplication):
|
|
|
1558
1558
|
# Get tables in this sheet
|
|
1559
1559
|
sheet_tables = analyze_sheet_for_tables(
|
|
1560
1560
|
self.get_values,
|
|
1561
|
-
|
|
1561
|
+
spreadsheetId,
|
|
1562
1562
|
sheet_properties.get("sheetId", 0),
|
|
1563
1563
|
sheet_title,
|
|
1564
1564
|
min_rows=2,
|
|
@@ -1586,19 +1586,19 @@ class GoogleSheetApp(APIApplication):
|
|
|
1586
1586
|
|
|
1587
1587
|
# Use the helper function to analyze the table schema
|
|
1588
1588
|
return analyze_table_schema(
|
|
1589
|
-
self.get_values,
|
|
1589
|
+
self.get_values, spreadsheetId, target_table, sample_size
|
|
1590
1590
|
)
|
|
1591
1591
|
|
|
1592
1592
|
def set_basic_filter(
|
|
1593
1593
|
self,
|
|
1594
|
-
|
|
1594
|
+
spreadsheetId: str,
|
|
1595
1595
|
filter: dict,
|
|
1596
1596
|
) -> dict[str, Any]:
|
|
1597
1597
|
"""
|
|
1598
1598
|
Sets or updates a basic filter on a specified range within a sheet, enabling data sorting and filtering. The filter's target range and optional sort specifications are defined in a dictionary argument. It is the counterpart to `clear_basic_filter`, which removes an existing filter.
|
|
1599
1599
|
|
|
1600
1600
|
Args:
|
|
1601
|
-
|
|
1601
|
+
spreadsheetId: The ID of the spreadsheet. Example: "abc123xyz789"
|
|
1602
1602
|
filter: The filter to set. This parameter is required. Contains:
|
|
1603
1603
|
- range: The range the filter covers (required)
|
|
1604
1604
|
- sheetId: The sheet this range is on (required)
|
|
@@ -1615,13 +1615,13 @@ class GoogleSheetApp(APIApplication):
|
|
|
1615
1615
|
|
|
1616
1616
|
Raises:
|
|
1617
1617
|
HTTPError: When the API request fails due to invalid parameters or insufficient permissions
|
|
1618
|
-
ValueError: When
|
|
1618
|
+
ValueError: When spreadsheetId is empty or filter is missing required fields
|
|
1619
1619
|
|
|
1620
1620
|
Tags:
|
|
1621
1621
|
filter, basic-filter, spreadsheet, sort, important
|
|
1622
1622
|
"""
|
|
1623
|
-
if not
|
|
1624
|
-
raise ValueError("
|
|
1623
|
+
if not spreadsheetId:
|
|
1624
|
+
raise ValueError("spreadsheetId cannot be empty")
|
|
1625
1625
|
|
|
1626
1626
|
if not filter:
|
|
1627
1627
|
raise ValueError("filter cannot be empty")
|
|
@@ -1635,7 +1635,7 @@ class GoogleSheetApp(APIApplication):
|
|
|
1635
1635
|
if "sheetId" not in range_data:
|
|
1636
1636
|
raise ValueError("filter range must contain 'sheetId' field")
|
|
1637
1637
|
|
|
1638
|
-
url = f"{self.base_url}/{
|
|
1638
|
+
url = f"{self.base_url}/{spreadsheetId}:batchUpdate"
|
|
1639
1639
|
|
|
1640
1640
|
request_body = {"requests": [{"setBasicFilter": {"filter": filter}}]}
|
|
1641
1641
|
|
|
@@ -1726,7 +1726,7 @@ class GoogleSheetApp(APIApplication):
|
|
|
1726
1726
|
|
|
1727
1727
|
Raises:
|
|
1728
1728
|
HTTPError: When the API request fails due to invalid parameters or insufficient permissions
|
|
1729
|
-
ValueError: When
|
|
1729
|
+
ValueError: When spreadsheetId is empty, indices are invalid, or color values are out of range
|
|
1730
1730
|
|
|
1731
1731
|
Tags:
|
|
1732
1732
|
format, cells, styling, text-formatting, background-color, borders, alignment, merge
|