+
+def renameSheet(turb, url, newName):
+ id = extractIdFromSheetUrl(url)
+ requests = []
+ requests.append({
+ 'updateSpreadsheetProperties': {
+ 'properties': {
+ 'title': newName
+ },
+ 'fields': 'title'
+ }
+ })
+
+ body = {
+ 'requests': requests
+ }
+
+ turb.sheets.batchUpdate(spreadsheetId = id,
+ body=body
+ ).execute()
+
+def extractIdFromSheetUrl(url):
+ # Google sheet ids are between the /d/ and /edit in the url, like
+ # https://docs.google.com/spreadsheets/d/1dxHBzjen...-LaXeVPrg/edit#gid=0
+ startIndex = url.find('/d/') + 3
+ endIndex = url.find('/edit')
+ return url[startIndex : endIndex]