I am trying to add columns to a Google Sheets, but I get an error. I need to add a copy of the previous column.
Code:
def insert_column():
sa = gspread.service_account(filename="service_account.json")
sh = sa.open("**NAME**")
wks = sh.worksheet("Class Data")
data = {
"requests": [
{
"insertDimension": {
"range": {
"sheetId": 0,
"dimension": "COLUMNS",
"startIndex": 4,
"endIndex": 5
},
"inheritFromBefore": True
}
},
],
}
wks.batch_update(data).execute()
An Error: TypeError: string indices must be integers
I think the problem is here wks.batch_update(data).execute()
, but I don't know how to solve it.