I am receiving a block of text via API. I want to save each word separated by a comma in a new field in the database. It’s possible?
For example. Words received: house, car, pot, table.
I want each of these objects to be a new entry in the database.
2 Likes
Explore how :format as text works
You need :extract with regex
Using pattern [^,]+
That will transform your one text value into a list of texts.
Then you can use api workflow on a list to create one record for each text in your new list
3 Likes
What Richard said . You might want to add something to remove the space after the comma. Either:
- Regex:
[^, ]+
or
- Bubble’s
:trim
operator.
4 Likes
I will test the suggestions and after give a feedback. Thanks!
Can I execute this same function with :format as text? If yes, can you explain how? I know that if possible we should avoid REGEX as much as possible because this can cause performance problems on the application.
Hi Italogmura,
To use :format as text, use “This Text” for the value, and “,” (comma, no quotes around it), for the separator.
See the attached image for an example.
Note that this works if you already have a “Bubble formatted” list, e.g., “word1 word2 word3”, etc. If you just have a long text/string, you don’t have the option to :format as text, as this is a method that works on lists. Depending on how you’re workflow is set up, you may want to parse the string into a list, e.g., using regex, to store in a database field, a list of texts, and then when you later want to convert it to CSV, use the :format as text option.
Also note, you probably don’t need to worry much about regex for simple lists, unless you’re doing a large volume of processing. It’s relatively slower, but it’s not usually absolutely slow.
Let us know if this helps!
3 Likes
Thank you! I will test this too.