---
title: "Walkthrough: Creating components to read and write data"
slug: "walkthrough--creating-components-to-read-and-write-data"
abstract: "How to create components to read and write data while synchronizing a text file using Sitecore Data Exchange Framework."
---
# Walkthrough: Creating components to read and write data

This walkthrough is part two of [Synchronizing data from a text file to Sitecore walkthrough series](https://doc.sitecore.com/xp/en/developers/def/80/data-exchange-framework/synchronizing-data-from-a-text-file-to-sitecore-walkthrough-series.html "Synchronizing data from a text file to Sitecore walkthrough series") and describes how to create the components you need in order to read data from a text file and write it to Sitecore.

The walkthrough describes how to:

- Add an endpoint for the source file.
- Add a set of value accessors for the source file.
- Add an endpoint for target items.
- Add a set of value accessors for the target items
- Add value mappings.

<details>
<summary><h2>Add an endpoint for the source file</h2></summary>

You use an endpoint to identify the text file that will be read.

To add an endpoint for the source file:

1. In the Content Editor, navigate to */sitecore/System/Data Exchange/File System Provider Test Tenant/Endpoints/Providers*.
2. To add a new template, in the right-hand pane, on the **Folder** tab, click **File System Endpoints**.

    > [!note]
    > This template is a command template. It does not prompt for the item name. The command template automatically assigns the item the name *File System*.

3. Navigate to the new *File System* folder. In the right-hand pane, on the **Folder** tab, click **Text File Endpoint**, and add the following item:

    | Template | *Text File Endpoint* |
    | --- | --- |
    | Name | *City Information File* |

4. Select the new *City Information File* endpoint.

    ![City Information File text file endpoint in the content tree](https://doc.sitecore.com/api/markdown-image/xp/en/developers/def/80/data-exchange-framework/images/city-information-file-endpoint.png)

5. In the right-hand pane, set the following field values:

    | Field | Value |
    | --- | --- |
    | **Path** | *C:\Sitecore\cities.dat* |
    | **Column Separator** | *,* |

6. Save the item.

</details>

<details>
<summary><h2>Add a set of value accessors for the source file</h2></summary>

To read values from the source file, you must create a value accessor for each value. Each value accessor represents a specific value from a row in the source file. You group related value accessors into value accessor sets, which can contain one or more value accessors.

Under a tenant, value accessor sets are organized by provider. You must create a folder to hold the value accessor sets for the new provider. You then create a value accessor set representing all the values you want to read from a row in the source file. In the value accessor set, you create value accessors that can read individual values from the source file data row.

To add a value accessor set with value accessors:

1. In the Content Editor, navigate to */sitecore/System/Data Exchange/File System Provider Test/Data Access/Value Accessor Sets/Providers*.
2. To add a new set, in the right-hand pane, on the **Folder** tab, click **File System Value Accessor Sets**.

    > [!note]
    > This template is a command template. It does not prompt for the item name. The command template automatically assigns the item the name *File System*.

3. To create a value accessor set, navigate to the new *File System* folder. In the right-hand pane, on the **Folder** tab, click **Array Value Accessor Set**. Name the new item *City Information File Fields*.
4. To create the value accessors, in the content tree, navigate to the new *City Information File Fields* item. In the right-hand pane, on the **Folder** tab, click **Array Value Accessor**. Name the new item *Identifier from City Information File*.
5. In the right-hand pane, set the following field value:

    | Field | Value |
    | --- | --- |
    | **Position** | *0* |

6. Save the item.
7. Repeat steps 1 to 3 to add two more Array Value Accessor items:

    | Item name | Position value |
    | --- | --- |
    | *Country from City Information Item* | *1* |
    | *City from City Information Item* | *2* |

</details>

<details>
<summary><h2>Add an endpoint for target items</h2></summary>

You use an endpoint to identify the Sitecore database where the Sitecore items will be created.

To add an endpoint:

1. In the Content Editor, navigate to */sitecore/System/Data Exchange/File System Provider Test Tenant/Endpoints/Providers*.

    ![Providers folder in the content tree](https://doc.sitecore.com/api/markdown-image/xp/en/developers/def/80/data-exchange-framework/images/endpoints-providers-file-system-provider-only.png)

2. In the right-hand pane, click *Sitecore Endpoints*.

    > [!note]
    > This template is a command template. It does not prompt for the item name. Command templates assign the item name automatically.

3. Select the new item.

    ![Sitecore endpoints folder in the content tree](https://doc.sitecore.com/api/markdown-image/xp/en/developers/def/80/data-exchange-framework/images/endpoints-providers-sitecore.png)

4. In the right-hand pane, click *Sitecore Item Model Repository Endpoint*. Name the new item *Sitecore Database Endpoint*.

</details>

<details>
<summary><h2>Add a set of value accessors for the target items</h2></summary>

To write values to the Sitecore items (target items) that act as the target objects, you must create a value accessor in the tenant for each item. Each value accessor represents a specific field on the template used for the target items. You group related value accessors into a value accessor set that represents all items you want to read from the source. You organize the value accessor sets in folders under the data provider.

To add value accessors for the target items:

1. To create a folder for the value accessor set, in the Content Editor, navigate to */sitecore/System/Data Exchange/File System Provider Test Tenant/Data Access/Value Accessor Sets/Providers*.

    ![Providers folder in the content tree](https://doc.sitecore.com/api/markdown-image/xp/en/developers/def/80/data-exchange-framework/images/value-accessor-sets-providers-file-system-configured.png)

2. In the right-hand pane, click *Sitecore Value Accessor Sets*.

    > [!note]
    > This template is a command template. It does not prompt for the item name. Command templates assign the item name automatically.

3. To create a value accessor set, in the Content Editor, navigate to the *Sitecore* provider.

    ![Sitecore provider in the content tree](https://doc.sitecore.com/api/markdown-image/xp/en/developers/def/80/data-exchange-framework/images/sitecore-provider-value-accessor-sets.png)

4. On the **Folder** tab, click **Sitecore Item Field Value Accessor Set** to create a new item, and name it *City Information Item Fields*.
5. To create the value accessors, in the Content Editor, navigate to the *City Information Item Fields* item.

    ![City Information Item Fields value accessor set in the content tree](https://doc.sitecore.com/api/markdown-image/xp/en/developers/def/80/data-exchange-framework/images/city-information-template-fields-value-accessor-set.png)

6. In the right-pane, on the **Folder** tab, click **Sitecore Item Field Value Accessor** to create a new item, and name it *Identifier on City Information Item*.
7. In the right-hand pane, set the following field value:

    | Field | Value |
    | --- | --- |
    | **Field** | *Templates/User Defined/City Information/Data/Identifier* |

8. Save the item.
9. Repeat steps 6 to 8 to add two more Sitecore *Item Field Value Accessor* fields:

    | Field name | Field value |
    | --- | --- |
    | *Country on City Information Item* | *Templates/User Defined/City Information/Data/Country* |
    | *City on City Information Item* | *Templates/User Defined/City Information/Data/City* |

</details>

<details>
<summary><h2>Add value mappings</h2></summary>

You use value mappings to associate a value accessor for a source object with a value accessor for a target object. Related value mappings are grouped together under a value mapping set.

In this example, you create a value mapping set to represent all of the values you must map from a row in a text file to a Sitecore item. You then create value mappings for the *Identifier*, *Country*, and *City* Sitecore items. These mappings associate the value accessors you use to read values from the text file with the value accessors you use to write values to the corresponding Sitecore item

To create a value mapping set with value mappings:

1. To create a value mapping set, in the Content Editor, navigate to */sitecore/System/Data Exchange/File System Provder Test Tenant/Value Mapping Sets*.

    ![Value Mapping Sets folder in Tenant Settings in the content tree](https://doc.sitecore.com/api/markdown-image/xp/en/developers/def/80/data-exchange-framework/images/value-mapping-sets-empty.png)

2. In the right-hand pane, on the **Folder** tab, click **Value Mapping Set**. Name it *Row from City Information File to City Information Item*
3. To create a value mapping, in the content tree, navigate to the new value mapping set.

    ![Row from City Information File to City Information Item value mapping set item in Value Mapping Sets folder in Content tree](https://doc.sitecore.com/api/markdown-image/xp/en/developers/def/80/data-exchange-framework/images/value-mapping-set-empty.png)

4. In the right-hand pane, on the **Folder** tab, click **Value Mapping**. Name the new item *Identifier*. Select the new item in the content tree.
5. In the right-hand pane, in the **Source** section, specify the following field values:

    | Field | Value |
    | --- | --- |
    | **Source Accessor** | *Data Access/Value Accessor Sets/Providers/File System/City Information File Fields/Identifier from City Information File* |
    | **Target Accessor** | *Data Access/Value Accessor Sets/Providers/Sitecore/City Information Item Fields/Identifier on City Information Item* |

    ![Source and target accessor fields.](https://doc.sitecore.com/api/markdown-image/xp/en/developers/def/80/data-exchange-framework/images/value-mapping-identifier.png)

6. Save the item.
7. Repeat steps 4 to 7 to add the following value mappings:

    | Name | Source accessor | Target Accessor |
    | --- | --- | --- |
    | *Country* | *Data Access/Value Accessor Sets/Providers/File System/City Information File Fields/Country from City Information File* | *Data Access/Value Accessor Sets/Providers/Sitecore/City Information Item Fields/Country on City Information Item* |
    | *City* | *Data Access/Value Accessor Sets/Providers/File System/City Information File Fields/City from City Information File* | *Data Access/Value Accessor Sets/Providers/Sitecore/City Information Item Fields/City on City Information Item* |

</details>