def create_spreadsheet_with_api(connection, filename):
try:
connection.open(filename)
if (no exception):
raise exception file already exists
if (there exception):
connection.create(filename)
Using pygsheets library which uses google api, I'm trying to create spreadsheet with given name, if it's not already exists.
I receive Exception pygsheets.exceptions.SpreadsheetNotFound:
So I need something like reverse Exception, or if there are better practice of doing it in python your advice will be highly appreciated.