Ollie
Ollie

Reputation: 13

TypeError: 'Worksheet' object is not callable

I'm trying to use the gspread module in Python, but everytime I want to duplicate a sheet, I get above mentioned error. How can I fix this. Reading the documentation, there's nothing to find in how to do it differently?

My code looks as follows:

import gspread
from oauth2client.service_account import ServiceAccountCredentials
from pprint import pprint

scope = ["https://spreadsheets.google.com/feeds",'https://www.googleapis.com/auth/spreadsheets',"https://www.googleapis.com/auth/drive.file","https://www.googleapis.com/auth/drive"]

creds = ServiceAccountCredentials.from_json_keyfile_name("creds.json", scope)

client = gspread.authorize(creds)

sh = client.open("Salary vs costs")

ws = sh.worksheet("Week 44")

ws.duplicate()(insert_sheet_index=None, new_sheet_id=None, new_sheet_name='Week 56t')

Upvotes: 0

Views: 1075

Answers (1)

Tom Wojcik
Tom Wojcik

Reputation: 6179

Replace

ws.duplicate()(insert_sheet_index=None, new_sheet_id=None, new_sheet_name='Week 56t')

with

ws.duplicate(insert_sheet_index=None, new_sheet_id=None, new_sheet_name='Week 56t')

duplicate returns a sheet and it's not callable.

Upvotes: 1

Related Questions