Function Repository Resource:

AssociationEditor

Source Notebook

Create an interface for editing an Association

Contributed by: Bob Sandheinrich

ResourceFunction["AssociationEditor"][assoc]

creates an interface for modifying the keys and values of assoc.

Details and Options

The editor interface has a row for each key-value pair. Each row contains an editable field for both the key and the value.
All fields support arbitrary expressions.
The editor contains an add button for adding key-value pairs to the Association.
The editor contains three buttons to retrieve the edited Association:
copy to put the Association on the clipboard
print to print the Association in the notebook
collapse to replace the editor with the Association
It is often easier to copy and paste expressions than to type them. A small copy button is provided next to each value to copy that value to the clipboard.

Examples

Basic Examples (3) 

Create an editor for a simple Association:

In[1]:=
ResourceFunction["AssociationEditor"][<|"a" -> 1, "b" -> 2|>]

Add a value with the add button:

Modify some values and print the updated Association:

Scope (1) 

Create an editor for real data:

In[2]:=
ResourceFunction["AssociationEditor"]@
 Normal@First@ResourceData["Sample Data: Crab Measures"]
Out[2]=

Possible Issues (2) 

Associations do not support repeated keys. When a key is used multiple times in the editor, only the last value appears in the output Association. Create an editor and add a key matching the first:

In[3]:=
ResourceFunction["AssociationEditor"][<|"a" -> 1|>]

The output only includes the last value of "a":


Large content can be ugly and difficult to use:

In[4]:=
ResourceFunction["AssociationEditor"][<|"a" -> Range[10^3]|>]

Version History

  • 1.0.0 – 07 May 2020

Related Resources

License Information