> For the complete documentation index, see [llms.txt](https://cgps.gitbook.io/data-flo/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://cgps.gitbook.io/data-flo/reference-guide/add-value-to-dictionary.md).

# add-value-to-dictionary

## Description

<mark style="color:purple;">`add-value-to-dictionary`</mark> *adaptor is used to add a key-value pair to an existing dictionary, or to a new dictionary if the* `dictionary` *input is not specified*.

By default, the adaptor will update the value if the key is already existing in the input dictionary. This can be changed by setting `overwrite` input to `False`.

## Inputs

**`dictionary`**\
Type: `dictionary`\
Required: No\
The dictionary to which the value will be added. If unspecified, the value will be added to a new dictionary.

**`key`**\
Type: `text`\
Required: Yes\
The key to be added to the dictionary.

**`value`**\
Type: `text`\
Required: Yes\
The value to be added to the dictionary.

**`overwrite`**\
Type: `boolean`\
Required: No\
Whether to overwrite the value if the specified key already exists in the dictionary. If unspecified, defaults to `True`.

## Outputs

**`dictionary`**\
Type: `dictionary`\
A dictionary containing the added value.

## Examples

### Example 1: Default behaviour.

#### Inputs:

`dictionary`:

<table><thead><tr><th width="100">KEY</th><th width="200">VALUE</th></tr></thead><tbody><tr><td>GB</td><td>United Kingdom</td></tr><tr><td>TR</td><td>Turkey</td></tr></tbody></table>

`key`: US `value`: United States

#### Outputs:

`dictionary`:

<table><thead><tr><th width="98">KEY</th><th width="200">VALUE</th></tr></thead><tbody><tr><td>GB</td><td>United Kingdom</td></tr><tr><td>TR</td><td>Turkey</td></tr><tr><td>US</td><td>United States</td></tr></tbody></table>

-> Added a new key-value pair { `US`: "`United States`" } to an existing dictionary.

### Example 2: Adding a key-value pair to a new dictionary.

#### Inputs:

`key`: GB

`value`: United Kingdom

#### Outputs:

`dictionary`:

<table><thead><tr><th width="100">KEY</th><th width="200">VALUE</th></tr></thead><tbody><tr><td>GB</td><td>United Kingdom</td></tr></tbody></table>

-> Added a key-value pair { `GB`: "`United Kingdom`" } to a new dictionary.

### Example 3: Updating an existing key in a dictionary.

#### Inputs:

`dictionary`:

<table><thead><tr><th width="100">KEY</th><th width="200">VALUE</th></tr></thead><tbody><tr><td>GB</td><td>United Kingdom</td></tr><tr><td>TR</td><td>Turkey</td></tr></tbody></table>

`key`: TR

`value`: Turkiye

#### Outputs:

`dictionary`:

<table><thead><tr><th width="100">KEY</th><th width="200">VALUE</th></tr></thead><tbody><tr><td>GB</td><td>United Kingdom</td></tr><tr><td>TR</td><td>Turkiye</td></tr></tbody></table>

-> Updated an existing dictionary with the key-value pair { `TR`: "`Turkiye`" }.

### Use Cases

* Represent associative data where there is a clear relationship between keys and values, such as mapping country codes to country names.
* Facilitate language translation by using key-value pairs where keys represent phrases or terms in one language, and values represent their translations in another language.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://cgps.gitbook.io/data-flo/reference-guide/add-value-to-dictionary.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
