Map an IMDb Genre list to a "Genres" table

Hi @Alan_Larsen1 - I’m the creator of the Pack, glad you’re enjoying it!

This took me a bit of hacking to get right, but here’s the formula that worked for me:

thisRow.[IMDb Genre List]
    .Split(", ")
    .ForEach(
        GenresTable.Filter(GenreName=CurrentValue)
    )
   .ListCombine()

So what the heck is going on here? Mostly a whole bunch of stuff to massage things into the type of data Coda is expecting at each stage. Let me break it down:

  • .Split(", ") - The list of genres is just a bunch of text; Coda doesn’t realize it’s a list. To convert it to a true list in Coda’s mind, we need to take that text, and split it up into separate items anytime we see ", " (a comma followed by a space)
  • Now we’ve got a list! Let’s look at each item in the list individually with forEach()
  • For each of these items, we want to match it to the corresponding record in our Genres table (GenresTable.Filter(GenreName=CurrentValue), where CurrentValue is the current item from that list we created, and GenreName is what I called my display column in my Genres table)
  • You’d think this would be enough lol, but the result comes out as [Action], [Drama] instead of Action, Drama, so we need to go one more step further and say “hey, everything that the ForEach function spits out? I want you to mash that all into a Coda list using ListCombine()” (because when Coda is asking you for multiple lookups, it’s asking you for a list of those lookups)

Phew! Maybe someone can come along with a more elegant solution (most of this is Coda fundamentals, not IMDb-Pack-specific), but in the meantime, this should work.

Also, curious about your use case! I’m always interested to hear what people are doing with the Pack.

Edit: Instead of ListCombine(), you could add .First() at the end of GenresTable.Filter(GenreName=CurrentValue). Up to you. The problem is that Filter() always returns a list, even if it’s a list of 1. You can either combine those lists together with ListCombine(), or force Filter() to return only the first (and usually only) item with .First()

*Edit2: In retrospect, I probably could have designed the Pack to spit out a list of text objects, not a single text object with commas in it. I might change this. If this formula breaks on you in the future, the solution will be to remove Split() (cause I’ll be doing that for you in the Pack)