Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Single word title for Google Spreadsheet #6510

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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
immortalcodes marked this conversation as resolved.
Show resolved Hide resolved
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
immortalcodes marked this conversation as resolved.
Show resolved Hide resolved
else:
return key, worksheet_num
immortalcodes marked this conversation as resolved.
Show resolved Hide resolved

else:
return key, worksheet_num


def parse_worksheet(worksheet):
Expand Down