# How to convert a nested list to a bulleted list

I have this list of lists:

``````List(1, List("A", "B", "C"))
``````

How can I turn it into:

• 1
• A
• B
• C

Can the same formula be made to work for:

``````List(2, List(1, List("A", "B", "C")))
``````

Is that what you wish ?

Cheers

Q

Yes this is the desired output, but I want both examples to be solved using the same formula.

thatâs a little âroughâ request from a community champâ âŚ !

At this point, did not figure out how to perform this without switchif (knowing that Iâm cheating )

Will your data always have that kind of format ? if yes I assume this switchif isnt such a bad idea, but otherwise itâs difficult to me seeing how to cut the list, knowing how many levels of bullet point I would require.

Slicing/spliting the list and you loose the information about sublist. Using First/Last makes me loose middle data from example 1. Then, calling for better coda maker and wizard than me on this subject

2 Likes

Is using a button an option, or does it have to be a live formula?

With a live formula this can be possible with some forced recalc magic to get it into a recursive loop.

Iâd also say maybe make a pack formula for it?

3 Likes

Hey Paul. Yes I also tought of a button that could make it easier. Thanks for sharing the while loop in live formula, could totally interest me for another project. Cheers.

Yeah pack is probably the move. I just really wanted to do it in native formulas.

Thanks to all, youâre helping me feel less dumb for not being able to figure it out.

Ok if it canât be in a simple formula, maybe it can be in a table formula.

Hereâs the doc Iâm working in:

Youâll see that there is a column called Subitems which nicely shows what an Item is made of:

Iâd like to be able to @ reference that Basket and see its makeup in a bulleted list like this:

1 Like

The tableâs rather easy, and I might have a wild idea with just random lists of text as well (provided all text pieces are unique). Itâs too late here though; Iâll update this post when Iâll have solved it in my tomorrow.

1 Like

Sorry, got busy for a few days.

Hereâs the table solution: recursive collection of data from items:

With regular text itâs a bit tricky because Coda tried to âfixâ the one vs list-of-one issue with another âmagicalâ behavior where the list of one is silently treated as an item on its own:

The crazy approach Iâd use here to determine whatâs the level of the nesting of each given item is toâŚ convert the list to text and calculate nesting by taking the number of `[`s and `]`s and subtracting one from another Of course this wonât work if the items themselves have `[]` characters (although it can be worked around with smarter regex) and if one item appears elsewhere, e.g. âCheeseâ and âCheese sticksâ might trigger faulty results because of a substring being found twice

``````WithName(Input + "", InputToText,
Input.ListCombine().ForEach(
InputToText.Find(CurrentValue).WithName(FoundPosition,
InputToText.Left(FoundPosition).WithName(AllPreText,
List(
AllPreText.RegexReplace("[^\[]", "").Length() - AllPreText.RegexReplace("[^\]]", "").Length(),
CurrentValue
)
))
).ForEach(
CurrentValue.Last().BulletedList().IndentBy(CurrentValue.First() - 1)
).Concatenate()
)
``````

Update: Fixed this by wrapping the list into an object first. This way Coda preserves the lists properly (turns it into proper JSON):

5 Likes

This is super useful Connor! (For some reason, the second video on the Items page is not working for me.)

1 Like

Glad itâs helpful! Can you tell me about the issue youâre running into with the second video? Iâm not able to replicate the issue

Yeah, the bulleted list issue was causing me problems. Why does BulletedList do that? Is it for any good reason or just a bug?

The solution should not be this complicated

Hi Connor, The video doesnât play on my end, but it could just be an issue for me.

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.