# dcupl and your PIM

dcupl is not a PIM. It has no screens for editing product values one by one,
and it doesn't replace the system your team maintains product data in. dcupl
loads your PIM's export, models it, checks it and serves it to your apps and
agents. It reads the export; it never writes back to your PIM.

When a value in the export is wrong, or an app needs an attribute the PIM
doesn't have, you don't need a second authoring tool or a change in the PIM.
Keep the fix in a small file in your dcupl project and load it on top of the
export. dcupl merges it into the PIM rows by product key.

```mermaid
flowchart LR
  P["Your PIM<br/>unchanged"] -->|"export"| E["pim-export.csv"]
  C["corrections.csv<br/>kept in the dcupl project"]
  E -->|"loaded first"| M["Product model<br/>in dcupl"]
  C -->|"merged on top, by sku"| M
  M --> A["Apps, REST APIs, agents"]
```

## What stays as it is

- **Your PIM stays the system of record.** Product data is maintained where it
  is today, by the same people, with the same approvals.
- **dcupl reads an export.** A file the PIM writes, or a URL that serves it. The
  Console's [import form](/console/data-import) either copies the file into the
  project or loads it from its URL on every load.
- **Nothing writes back.** Queries, REST APIs and the MCP tools answer from
  the data dcupl loaded, not from your PIM, and change nothing in it. A
  workflow calls your PIM's API only if your team builds one that does.

## Load corrections on top of the export

The example has three products in the PIM export. The correction file fixes one
price and adds an eco label that the PIM doesn't have.

```json filename="models/product.dcupl.json"
{
  "key": "Product",
  "keyProperty": "sku",
  "properties": [
    { "key": "name", "type": "string" },
    { "key": "brand", "type": "string" },
    { "key": "price", "type": "float" },
    { "key": "ecoLabel", "type": "string" }
  ]
}
```

```csv filename="data/pim-export.csv"
sku,name,brand,price
A-100,Cordless drill,Bosch,129.00
A-200,Impact driver,Makita,149.00
A-300,Angle grinder,Bosch,89.00
```

```csv filename="data/corrections.csv"
sku,price,ecoLabel
A-200,139.00,
A-300,,EU Ecolabel
```

The correction file comes after the export in `dcupl.lc.json` and has
`"updateType": "update"`:

```json filename="dcupl.lc.json"
{
  "resources": [
    { "url": "${baseUrl}/models/product.dcupl.json", "type": "model" },
    { "url": "${baseUrl}/data/pim-export.csv", "type": "data", "model": "Product" },
    {
      "url": "${baseUrl}/data/corrections.csv",
      "type": "data",
      "model": "Product",
      "options": { "updateType": "update" }
    }
  ]
}
```

The loaded `Product` model then holds:

| sku   | name           | brand  | price   | ecoLabel        |
| ----- | -------------- | ------ | ------- | --------------- |
| A-100 | Cordless drill | Bosch  | 129     |                 |
| A-200 | Impact driver  | Makita | **139** |                 |
| A-300 | Angle grinder  | Bosch  | 89      | **EU Ecolabel** |

The PIM export is untouched. Its next version loads the same way, and the
corrections apply again on top. Once the PIM carries the fix, delete the row
from the correction file.

## How the merge works

- **Order.** The data files of one model apply in the order of `resources` in
  `dcupl.lc.json`, whatever order they finish downloading in. The export loads with
  the default `updateType`, `set`, which replaces all rows of the model. List
  the correction file after it: listed before it, the export replaces the
  corrected rows.
- **Per attribute.** A value in the correction file replaces the export's
  value. An attribute the file doesn't have, or an empty CSV cell, keeps the
  export's value. To clear a value, write `null` in its cell (in a JSON file,
  the value `null`). An array or object value is replaced as a whole, not
  merged item by item.
- **Matched by key.** Both files carry the model's key property (`sku` here).
  A row whose key the export doesn't have changes nothing with `update`, so a
  mistyped SKU never adds a product. Use `"updateType": "upsert"` instead when
  the file should also add products that exist only in dcupl.
- **Several files.** Keep as many correction files as you need, for example one
  per team or one per purpose. They apply one after the other, in the same
  order, so where two files set the same value, the later file wins.

## Who edits the correction file

The correction file is a project file like any other. Your team edits it in
the Console's file editor, or in a spreadsheet and pushes it with
`dcupl files push` (see [How the CLI works](/cli/how-it-works)).

To add it in the Console, upload it with the [import form](/console/data-import)
and pick the existing model. The form adds the file's entry at the end of
`resources` in `dcupl.lc.json`, with no `updateType`, so it would load as a
`set` and replace the export's rows. Open `dcupl.lc.json` in the file editor
and add `"options": { "updateType": "update" }` to that entry. The loader form
keeps the option when you edit the entry later.

## Next steps

- [Serve data from exported files](/learn/best-practices/exported-files) — keep the source system off the internet and serve its exports
- [Loader configuration](/console/loader) — resources, tags and applications in `dcupl.lc.json`
- [SDK loader reference](/sdk/api/loader#resource-types) — `updateType`, `keyProperty` and the other data resource options
- [Importing data](/console/data-import) — what the import form writes
