jacobcan118
jacobcan118

Reputation: 9037

How to set dynamically "range" for google sheet when add data from panda

I would like to append data from pandas to google sheets using google sheets api. checking the document, it require parameter range. so far I set the max possible value in google sheets, see similar post how to set cells range dynamically in Google sheets. but it does not solve my question. so anyway I can use dynamically?

batch_update_spreadsheet_request_body = {
            'majorDimension': 'ROWS',
            'values': df.values.tolist(),
        }
response = service.spreadsheets().values().append(spreadsheetId=google_sheets_id, valueInputOption='RAW', body=batch_update_spreadsheet_request_body, range='A1:AA1000').execute()

Upvotes: 0

Views: 706

Answers (1)

TheMaster
TheMaster

Reputation: 50462

As written in the documentation,

When appending values, this field represents the range to search for a table, after which values will be appended.

So, You only need to add the left top cell range of the table you're trying to append to.

Upvotes: 1

Related Questions