I have created a python script that sets a filter on my google sheet. This filtering works as expected. I'm now interested in grabbing all the rows after setting this filter. However, when I do get api call, I'm getting all the rows.
I think I'm making a mistake in providing the range when I make get call. I provide range in this format Sheet1!A:J
. This range indicates all data in columns from A to J. However, I don't know how to provide only range corresponding to filtered data. I have seen one solution in google app script described in this post (https://sites.google.com/site/scriptsexamples/learn-by-example/google-sheets-api/filters#TOC-Get-filtered-rows). However, this is quite an inefficient solution. I don't want to run for loop on fetched data. I want to prevent fetching all data, and would rather prefer to fetch only the filtered data. Is that possible to do from python script?
I currently do it like this
# print(json.dumps(body, indent=4))
resp = service.spreadsheets() \
.batchUpdate(spreadsheetId=SAMPLE_SPREADSHEET_ID, body=body).execute()
sheet = service.spreadsheets()
data = sheet.values().get(spreadsheetId=SAMPLE_SPREADSHEET_ID, range="Sheet1!A:J").execute()
print(data)
How to get only filtered columns from google sheets to python script using google API?
, it seems that you want to retrieveonly filtered columns
. But in your question, fromI'm now interested in grabbing all the rows after setting this filter.
, it seems that you want to retrieverows
. So I cannot understand about your goal. I apologize for this. Can I ask you about the detail of your goal? – TanaikeTEXT_EQ
value"Open"
, I want to fetch all the rows with value"Open"
in certain column. Is this clear now or I need to elaborate more? – Ruchit Patel