Write a question about a tab of your spreadsheet and get back a chart of the numbers already in it, recorded on your answers tab.
Uses
Google Sheets
OpenAIQuickChart
Ask a question about your sheet, get a chart back
spreadsheetUrl to blank.Set spreadsheetUrl to blank.dataTabName to blank.Set dataTabName to blank.question to blank.Set question to blank.answerTabName to Chart answers.Set answerTabName to Chart answers.maxPointsOnChart to 24.Set maxPointsOnChart to 24.spreadsheetUrl. Save it as tab.Read the rows of spreadsheetUrl. Save it as tab.headings to tab.headers.Set headings to tab.headers.tab.rows to text and save it as sampleRow.Convert the first item of tab.rows to text and save it as sampleRow.headings is emptyIf headings is emptyYes
No
No steps
promptIntro to You are choosing what to plot from one spreadsheet tab so that one question can be answered as a chart.Set promptIntro to You are choosing what to plot from one spreadsheet tab so that one question can be answered as a chart.
The question: question
The tab's column headings: headings joined by , .prompt to promptIntroSet prompt to promptIntro
One example row: sampleRow
Answer with exactly one line, in this form:
label column ||| value column ||| chart type
Use the column headings exactly as they are written above - do not invent a column, rename one, or answer with a column that is not listed. The value column must be the one holding the numbers to plot. The chart type must be one of bar, line or pie. Write nothing else.answerText to blank.Set answerText to blank.chooseErrorIf a step below fails, save the error as chooseErrorTry
answerText.Trim the response text from the OpenAI “Ask OpenAI” step and save it as answerText.On error
The step that chooses the columns did not answer this run..Show in the output: The step that chooses the columns did not answer this run..answerText is emptyIf answerText is emptyYes
No
No steps
answerText by ||| and save it as choice.Split answerText by ||| and save it as choice.choice is less than 3If the length of choice is less than 3Yes
answerText truncated to 120 characters.Stop and report a problem: The columns to chart could not be read from this answer: answerText truncated to 120 characters.No
No steps
choice and save it as labelColumn.Trim the first item of choice and save it as labelColumn.choice[1] and save it as valueColumn.Trim choice[1] and save it as valueColumn.choice lowercase and save it as chartType.Make the last item of choice lowercase and save it as chartType.headings doesn't contain labelColumnIf headings doesn't contain labelColumnYes
headings joined by , .Stop and report a problem: There is no column headed '@labelColumn' on that tab. Its columns are: headings joined by , .No
No steps
headings doesn't contain valueColumnIf headings doesn't contain valueColumnYes
headings joined by , .Stop and report a problem: There is no column headed '@valueColumn' on that tab. Its columns are: headings joined by , .No
No steps
labelColumn in headings and save it as labelIndex.Find the position of labelColumn in headings and save it as labelIndex.valueColumn in headings and save it as valueIndex.Find the position of valueColumn in headings and save it as valueIndex.labelIndex is greater than 25 or valueIndex is greater than 25If labelIndex is greater than 25 or valueIndex is greater than 25Yes
No
No steps
columnLetters to [A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X, Y, Z].Set columnLetters to [A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X, Y, Z].labelLetter to columnLetters[@labelIndex].Set labelLetter to columnLetters[@labelIndex].valueLetter to columnLetters[@valueIndex].Set valueLetter to columnLetters[@valueIndex].labelCells to the values from the Google Sheets “Read column” step.Set labelCells to the values from the Google Sheets “Read column” step.valueCells to the values from the Google Sheets “Read column” step.Set valueCells to the values from the Google Sheets “Read column” step.labelCells is not labelColumn or the first item of…If the first item of labelCells is not labelColumn or the first item of…Yes
labelLetter is headed 'the first item of labelCells' and column valueLetter is headed 'the first item of valueCells', which is not what was chosen. Nothing was charted.Stop and report a problem: Column labelLetter is headed 'the first item of labelCells' and column valueLetter is headed 'the first item of valueCells', which is not what was chosen. Nothing was charted.No
No steps
chartLabels to an empty list.Set chartLabels to an empty list.chartValues to an empty list.Set chartValues to an empty list.valuesSkipped to 0.Set valuesSkipped to 0.cursor to -1.Set cursor to -1.labelCell in labelCells:For each labelCell in labelCells:cursor.Add 1 to cursor.cursor is 0If cursor is 0Yes
No
No steps
chartLabels is greater than or equal to maxPointsOnChart…If the length of chartLabels is greater than or equal to maxPointsOnChart…Yes
No
No steps
labelCell and save it as labelRaw.Trim labelCell and save it as labelRaw.labelRaw is empty or labelRaw is nullIf labelRaw is empty or labelRaw is nullYes
No
No steps
labelRaw with , replaced by with , replaced by and save it as labelClean.Trim labelRaw with , replaced by with , replaced by and save it as labelClean.labelClean is emptyIf labelClean is emptyYes
No
No steps
valueCells[@cursor] and save it as valueRaw.Trim valueCells[@cursor] and save it as valueRaw.valueRaw is empty or valueRaw is nullIf valueRaw is empty or valueRaw is nullYes
valuesSkipped.Add 1 to valuesSkipped.No
No steps
valueRaw and save it as valueNumber.Extract the first number from valueRaw and save it as valueNumber.valueNumber is blankIf valueNumber is blankYes
valuesSkipped.Add 1 to valuesSkipped.No
No steps
labelClean to the end of chartLabels and save it as chartLabels.Add labelClean to the end of chartLabels and save it as chartLabels.valueNumber to the end of chartValues and save it as chartValues.Add valueNumber to the end of chartValues and save it as chartValues.chartLabels is emptyIf chartLabels is emptyYes
No
No steps
chartLabels with , and save it as labelsText.Join chartLabels with , and save it as labelsText.chartValues with , and save it as valuesText.Join chartValues with , and save it as valuesText.question to 90 characters and save it as chartTitle.Shorten question to 90 characters and save it as chartTitle.chartUrl to blank.Set chartUrl to blank.chartType is pieIf chartType is pieYes
chartUrl.Trim the url from the QuickChart “Create pie chart” step and save it as chartUrl.Else if @chartType is "line"
chartUrl.Trim the url from the QuickChart “Create line chart” step and save it as chartUrl.Else if @chartType is "bar"
chartUrl.Trim the url from the QuickChart “Create bar chart” step and save it as chartUrl.Otherwise
chartUrl doesn't start with https:// (ignoring case)If chartUrl doesn't start with https:// (ignoring case)Yes
No
No steps
skippedNote to blank.Set skippedNote to blank.valuesSkipped is greater than 0If valuesSkipped is greater than 0Yes
skippedNote to valuesSkipped row(s) were left off the chart because their value could not be read as a number.Change skippedNote to valuesSkipped row(s) were left off the chart because their value could not be read as a number.No
No steps
answerTabName in spreadsheetUrl.Add a row to answerTabName in spreadsheetUrl.chartUrl skippedNote.Show in the output: Chart: chartUrl skippedNote.