Hi @Anna_F !
Sorry for the late reply .
Before going into the formula part, I thought about something that might simplifies things a little :
Did you try to paste the output you get from GPT using :
⌘ cmd/ctrl on Windows + ⇧ shift + v (which is the shortcut for
Paste and match style on Chrome or any other browser I think)
or did you use
⌘ cmd/ctrl + v (which well, simply paste)
I’m asking because using one or the other could give different result
(But it still might not solve the issue though )
In the sample you’ll find below, I tried my best to reproduce the output you get from GTP once pasted into a text field in Coda.
This is the value in the field called
[Input - Spaces instead of tabs] in the table
[Spaces > Tabs].
I assumed , from your screenshot, that each line representing a “row” was separated by a newline (
"\n") and because only the spaces between the “columns” in each of these rows are the ones we’re interested in, the first step is to replace each newline in the whole text value pasted from GPT by something else, something easily identifiable (here I chose a comma (
",") but it could be any character, as long as it’s a character you don’t use anywhere else in the output you pasted from GPT)
This is done in the field
[1 - RegexReplace() "\n" by ","] with this formula :
thisRow.[Input - Spaces instead of tabs].RegexReplace("\n",",")
where RegexReplace() checks each character in
thisRow.[Input - Spaces instead of tabs] and replace each newline character it finds (
"\n") by a simple comma (
This outputs another text value as a whole (another entire string)
We can then Split() this text value by the commas to create a list of text values where one text value in the list is a “row” from the “table” you pasted.
This is done in the field
2 - Split() and the formula is one :
thisRow.[1 - RegexReplace() "\n" by ","].Split(",")
And now, the last step would be to finally replace the spaces between the “columns” for each text value (“row”) in the list of text values
Split() returned .
(Note In Coda, each of these text values in the list is stored as/represented by
Which is done with this formula :
thisRow.[2 - Split()].ForEach(
Which takes the list of text values
Split() previously outputted and for each (ForEach()) text value in the list (
CurrentValue), we ask
RegexReplace() to go through each character, find any spaces (
"\s") and replace them by a tab (
ForEach() always outputs a list (of text values in this case), we Join() each item in the list by a
All in one formula is this one :
thisRow.[Input - Spaces instead of tabs]
The output of the formula can be copied and pasted to be directly converted into a brand new table, as long as you use ⌘ cmd/ctrl + ⇧ shift + v to “
Paste and match style”
Now, as it seems that you can ask GPT to format its output maybe, if you know you’ll be using the output in Coda, you could directly ask for a different format, something that would require less steps in the conversion/manipulation of the initial string .
E.g.: Have each “row” separated by a comma and each “column” separated by a pipe (
(See the table
[Input - Different formatting] below the 1st table in the sample)
This would suppress the need for the very first
RegexReplace() and the formula could look like :
thisRow.[Input - Different formatting].Split(",").ForEach(
(In RegEx, a pipe (
|) needs to be escaped (
"\|") to be considered as a character, as it has a special meaning/use)
Note that because I had to assume how the output you get from GPT is formatted, this might not work at the 1st try .
(In that case, don’t hesitate to share a sample doc with the exact formatting you get from GPT)
In the meantime, I hope this helps