Skip to content

Commit

Permalink
Update google_spreadsheets.py
Browse files Browse the repository at this point in the history
  • Loading branch information
immortalcodes authored Oct 8, 2023
1 parent 138339a commit 81b9feb
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions redash/query_runner/google_spreadsheets.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,18 +100,28 @@ def __init__(self, worksheet_title):
def parse_query(query):
values = query.split("|")
key = values[0] # key of the spreadsheet
worksheet_num_or_title = 0 # A default value for when a number of inputs is invalid
worksheet_num = 0 # A default value for when a number of inputs is invalid
worksheet_title = '' # No title initially
if len(values) == 2:
s = values[1].strip()
if len(s) > 0:
if re.match(r"^\"(.*?)\"$", s):
# A string quoted by " means a title of worksheet
worksheet_num_or_title = s[1:-1]
else:
worksheet_title = s[1:-1]
elif re.match(r"^\d+$", s):
# if spreadsheet contains more than one worksheet - this is the number of it
worksheet_num_or_title = int(s)

return key, worksheet_num_or_title
worksheet_num = int(s)
else:
# To match for non-quoted one-word file name
if len(s.split()) == 1 :
worksheet_title = s
if worksheet_title != '':
return key, worksheet_title
else:
return key, worksheet_num

else:
return key, worksheet_num


def parse_worksheet(worksheet):
Expand Down

0 comments on commit 81b9feb

Please sign in to comment.