I tried to remove the worksheet in Google docs file. I am using Pygsheets to perform this process. There's only one sheet in that file. So we can't remove the sheet. so it will throw the Error. How i handle it Separately. Below is i tried something. but its not working
def deleteWorksheets(file_name=None, sheet_name=None):
try:
sheet = client.open(file_name)
delete_worksheet = sheet.worksheet_by_title(sheet_name)
sheet.del_worksheet(delete_worksheet)
except urllib.error.HTTPError:
print("You can't remove")
Below error is shown. How to handle it Separately .
<HttpError 400 when requesting https://sheets.googleapis.com/v4/spreadsheets/ returned
"Invalid requests[0].deleteSheet: You can't remove all the sheets in a document.">