# Export and import the tag database as CSV

> Export every declared variable of an eaxPLC project with its type, address, initial value, access, write range and documentation as CSV, edit it in a spreadsheet, and import it back with a preview; what each column means, what an empty cell does, and how the import writes drafts and documentation.

Product: eaxPLC · Type: How-to guide · Editions: Free, Pro
Source: https://eaxware.com/docs/eaxplc/how-to/export-and-import-the-tag-database/
Verified against commit 9828d73.

## Goal

You edit many variables at once in a spreadsheet (documentation, access, write ranges, new globals) and bring the result back into the project, seeing exactly what will change before anything does.

## Before you start

- Exporting needs any signed-in user; importing needs an engineer.
- An import never saves a revision and never deploys. Declaration changes go to the **drafts** of the POUs you have checked out; documentation goes straight to the documentation files. To run declaration changes you save the drafts, then **Test edits** or **Build & Deploy**.

## 1. Export

1. Click **Tags**, then **Export CSV** (at narrow widths: **More (⋯) → Export CSV**).
2. Pick the **Separator** and click **Export**. Use a semicolon for a spreadsheet set to a decimal comma.
3. The file holds the current revision's saved declarations (never a draft) and their documentation.

Use **Export CSV** for a file you will import again. The small **CSV** button next to the grid's row count exports the rows as shown, with display texts, and is meant for reading.

The file is UTF-8 with a byte-order mark (spreadsheets then read accents right), CRLF line ends, RFC 4180 quoting. A cell that starts with `=`, `+`, `-`, `@`, a tab, a carriage return or `'` gets a leading `'`, so a spreadsheet never runs it as a formula; the import removes that `'` again. The route is `GET /api/project/tags/export?format=csv&sep=;` (`sep`: comma, semicolon or tab).

## 2. Edit

| Column | Meaning | Kept in |
|---|---|---|
| `scope` | `GLOBAL:<list>`, `PROGRAM:<program>` or `MAIN` | |
| `pou` | the declaring POU (a GVL or a PRG) | |
| `name` | the variable's name | |
| `type` | the declared type as written (`REAL`, `ARRAY[1..20] OF ST_Recipe`) | declaration |
| `address` | a direct address (`%QX0.1`), an alias target (`Motors[3].Run`, `Status.3`), or empty for automatic | declaration |
| `initial` | the initial value as written | declaration |
| `constant`, `retain` | `TRUE` or `FALSE` | declaration |
| `access` | `none`, `read`, `read_write`, or empty for the default | declaration |
| `write_range` | `low..high`, or empty | declaration |
| `description`, `unit`, `display`, `notes` | documentation; description and notes may hold line breaks | documentation file |

Rules for your edits:

- Columns can be in any order and are found by their header. A column you delete means "leave as it is". Unknown columns are ignored and listed.
- A present but **empty** cell **clears** the value: no initial value, automatic address, default access, no write range, empty description. The exception is `type`: an empty type leaves it unchanged.
- A row needs its `scope` or its `pou`. A new name is a new variable; a new variable without an `access` gets `read`.
- The separator (comma, semicolon or tab) is detected from the header row. The byte-order mark is optional.
- At most 4 MB and 50,000 rows.

## 3. Import with a preview

1. Click **Import CSV** and choose the file. Click **Preview**.
2. The preview lists each row with its status in the row:

   | Status | Meaning |
   |---|---|
   | **Add** | a new variable |
   | **Change** | a variable that changes; the changed columns are listed |
   | **Same** | nothing changes |
   | **Error** (rose) | the row cannot be applied; the message says why and gives the line |
   | **Needs lock** (amber) | the row is valid, but its POU is not checked out by you |

3. Fix errors in the file and preview again.
4. Click **Apply N changes**. When rows need POUs you have not checked out, the Studio offers **Check out and apply**. The import is all or nothing: it is refused while any row is an error (`400`) or needs a lock you do not hold (`423`, listing the POUs).

## Result

- Declaration changes are in the drafts of their POUs, with **draft** marks in the tag database. Open each POU (**Go to**), check it and save it, then test or deploy.
- Documentation changes are saved at once (no deploy).
- The PLC's audit trail holds `PROJECT_EXPORT` and `PROJECT_IMPORT`.

## Troubleshooting

| Message | Fix |
|---|---|
| *N cells, the header has M* | A row has more cells than the header. Check quoting around commas. |
| *column N is not UTF-8 text (save the file as CSV UTF-8)* | Save as "CSV UTF-8" in your spreadsheet. |
| *the row needs its scope or pou* | Fill in one of them. |
| *scope X and pou Y disagree* | The two columns name different POUs. |
| *access "rw" is none, read or read_write* | Use one of the three values. |
| *a CONSTANT is never written from outside: its access is read or none* | Leave access empty or set `read` on constants. |
| *address "..." is neither a direct address nor an alias target* | Use `%IX0.0`, `%QW4`, `%MD8`, or a target like `Motors[3].Run`. |
| *X is already on line N* | The file declares the variable twice. |

## Related

- [Document variables without a deploy](/docs/eaxplc/how-to/document-variables/)
- [Set external access and write limits](/docs/eaxplc/how-to/set-external-access-and-write-limits/)
- [Exchange data types and global variables as PLCopen XML](/docs/eaxplc/how-to/exchange-plcopen-xml/)
