# Create dictionary from table

**URL:** <https://community.influxdata.com/t/create-dictionary-from-table/17532>\
**Category:** Fluxlang\
**Tags:** flux\
**Created:** [January 7, 2021, 5:14pm UTC](https://community.influxdata.com/t/create-dictionary-from-table/17532 "2021-01-07T17:14:47Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![bknoth](https://avatars.discourse-cdn.com/v4/letter/b/958977/32.png) [@bknoth](https://community.influxdata.com/u/bknoth)\
**Post date:** [January 7, 2021, 5:14pm UTC](https://community.influxdata.com/t/create-dictionary-from-table/17532/1 "2021-01-07T17:14:47Z")

</div>

array.from() creates a table from a list of records. Does anyone know of a way I can do the opposite and construct a list of records from a table? I’d like to then use dict.fromList to create a dictionary from that list of records, but I can’t find a way to make it work.

Let’s assume I have some table that is formatted such:

lookupTable = someOtherTable  
|\> map(fn: ® =\> ({r with  
key: r.name,  
value: r.color  
}))  
|\> keep(columns: [“key”, “value”])

so, now I’d like to do this:

lookupDict = dict.fromList(pairs: lookupTable)

so that I can write a function like this:

findColor = (n) =\> dict.get( dict: lookupDict , key: n, default: “” )

The idea here is to be able to use this dictionary lookup rather than a join which takes an incredibly unfortunate huge amount of time.

This fails though at the dict.fromList with:

```auto
 error calling function "fromList" @34:19-34:71: keyword argument "pairs" should be of an array of type object, but got an array of type [t5751]

```

Thanks for any suggestions.

Brian

---

<div class="post-metadata">

**Author:** ![scott](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/scott/32/16492_2.png) [@scott](https://community.influxdata.com/u/scott)\
**Post date:** [January 8, 2021, 4:49pm UTC](https://community.influxdata.com/t/create-dictionary-from-table/17532/2 "2021-01-08T16:49:39Z")

</div>

Thanks @bknoth. This currently isn’t possible, but I’ve created a related issue in the Flux repo:

[Extract a table as a usable array · Issue #3424 · influxdata/flux · GitHub](https://github.com/influxdata/flux/issues/3424).

---

<div class="post-metadata">

**Author:** ![bknoth](https://avatars.discourse-cdn.com/v4/letter/b/958977/32.png) [@bknoth](https://community.influxdata.com/u/bknoth)\
**Post date:** [January 8, 2021, 5:12pm UTC](https://community.influxdata.com/t/create-dictionary-from-table/17532/3 "2021-01-08T17:12:54Z")

</div>

@scott , thank you. I think the example you show in the ticket is precisely what we need.
