Turn comma-separated items into a list of unique values

I’m trying to take a simple comma-separated list and convert it into unique values so that I can parse them in other tables.

For example: I have the text “dog, cat, fish” in a cell. Coda sees this as one value of “dog, cat, fish”.

When I try to convert above text into a list - either using List() or ListCombine() - Coda returns [(dog, cat, fish)] instead of [(dog),(cat),(fish)]. Unique() doesn’t do what I need it to here either, because it sees only one value instead of three.

Context: I am trying to format a column as a multi-select list - I want to be able to select any/all of “dog”, “cat”, or “fish”, but I cannot get them to appear as unique values - they always appear as “dog, cat, fish” instead. See below - Nth(1) should return “dog”, but instead it returns “dog, cat, fish”.

03%20AM

How do I do this? Sorry if the formatting in my question is weird, I’m not a natural programmer.

1 Like

@Brenton_Murrell

The first step is to convert your comma separated list into a list object. Split() returns a list of items.
NOTE: column [list bullets] is actually =split.BulletedList()

split_2019-02-04_1019

The next step is to get that list into a multi-select dropdown. There are a few ways to do this. Since I don’t know exactly what your end use is, I can’t suggest one way over another.

However, you caused me to figure out something that I will now use in one of my own workflows, so thanks!! :muscle: (see below)



9 Likes

Yes! That does it! Thank you - Split() is exactly what I needed

2 Likes

This got me 95% of the way to converting my comma-separated list of values (as pasted in from Excel) into a list that works properly as a select list. Then I added one more column that automatically selects/fills in the correct items from the select list using the simple formula, “thisRow.SplitKeywords”. Here’s how that looks in my case.

@Alexandra_Samuel

Is this what you want?

keyword_select_list_2019-09-22_1925

Here’s a sample doc:

1 Like

nope, what I want is what I’ve already got – as per my screenshot. I was just sharing in case anyone else was wondering how to actually populate the cell with the correct items from their select list, once they’d used your approach to create the selectable list of options.

1 Like

And here is a slightly different way to add the values to a different table so you can use that as a Lookup table.

3 Likes

I cannot get this to work. It takes my items and puts them still as one item instead of splitting them into 2 separate items. No, I don’t have a doc I can share. I just have a text field. I have Liver Support, CLA in that field and when I make a new field that says Items.Split(",") it still shows them exactly the same way in this new field and not making them into a list so the next step doesn’t work it still just shows “Liver Support, CLA” together. ARGH! What is the problem here?

@Susan_M_Davis

Tough to say without seeing what’s going on in the doc. If you can create a dummy doc that’s logically identical to your main doc, and share it here, we can probably spot your issue very quickly. (More likely is that you will spot the issue yourself while replicating your logic into a dummy doc.:grinning:)

NOPE. Because when I create a brand new table in a brand new document and put in just a few fields, it works as it should. So why using the exact same names and logic does it refuse to split my items in an existing table? This isn’t the first time I’ve seen strange behavior from Coda. I’ve had formulas that work one day then the next day they don’t and I didn’t change them. One day all my formulas for today evaluated to yesterday for about 30 minutes then all started working again. It’s just odd behavior and I don’t want to delete all the data I have and create a new table to fix the problem. I have way too much data for that. I’ve tried deleting columns, making new ones, etc. Still in this one table Split refuses to split the items. I even put in another field for count. In a new document it works as it should. In the existing one it still considers both of these items to be one and is refusing to split them.

Hi @Susan_M_Davis ,
I read your frustration, but, as @Ander suggests, the possibility to have a look would surely help to help you.
I can tell you that Coda formulas - and overall document behaviour - is indeed pretty stable; and I have worked on a great number of complex documents.

The first thing that comes to my mind is that the comma used in the paragraph isn’t the same unicode character you’re using in the Split() formula.
Could you copy/paste just a chunk of it here?

Thank you.

@Federico_Stefanato I finally got it working. I’m not saying Coda seems unstable, but I have seen some quirkiness with formulas that even Coda cannot explain. Like this one. Once I deleted the entire field and retyped the data it started working. I had to delete each item and re-input them. They were not copied and pasted from somewhere else. I use the same computer, same keyboard and just click the “,” to get a comma. So if it had the wrong character code that’s on the browser or coda because I didn’t do anything different.

The other day I logged into the page I use daily and all my formulas were wrong. They were a day off. My system date was fine, my doc date was set to the same time zone, etc. But everything I do that uses today() was showing me the wrong date. I did a few things I needed to do, came back and all the dates were fine again.

QUIRKY.

Is it the browser that causes this quirkiness? Is it some issue in Coda that causes these things to act up? Is it the internet instability that causes it? I don’t have the tools to diagnose the why it happens. I just know that I’ve seen a formula work perfectly one day and the next day it won’t work at all then for no reason, with no changes it starts working again.

Sometimes it is text fields and if you delete the data in the field and retype it, it works. Not sure why.

But I got it working yesterday by deleting and retyping all the fields I needed.

Hi @Susan_M_Davis,
firstly, I’m happy that you sorted out your issue.

It is quirky indeed and very honestly it sounds pretty strange as I never heard of something likewise before.
If you can’t share your document here for a formula inspection, you can ask for technical assistance (through the “?” on bottom-right of your page) next time something inexplicable happens.

I hope you won’t need to retype anything again!
Let me know

1 Like