How to filter raw text output and then do calculations to display a new output

Hi, So I created an app that allows you to upload an image and then using Cogniflow API it outputs the objects in the image and how many objects as text. For example this is the text output of an image I uploaded(lets call it OutputA):
|chair: 6
|dining table: 1
|potted plant: 1
|vase: 1
I have added another button called calculate and another text field called OutputB. Before displaying the text in outputB I want to do the following:

  1. Search outputA for an item e.g. “chair”, I then want to get the number next to it so in this example 6.
    2.Once it finds an item I want to times the value by 0.5(value will be different depending on what item is found).
  2. I also want to have a total tally displayed at the end.
  3. So outputB should look something like this:
    Chair: 3
    Dining table: 0.5
    Potted plant: 0.5
    Vase: 0.5
    Total: 4.5

Using normal code this would be pretty simple but I am new to using bubble and I have no idea how to split data, create arrays/objects filter etc

This topic was automatically closed after 70 days. New replies are no longer allowed.